darobin/respec — pull request #287 by sglaser (2013-12-10 03:15:20+00:00)
Title: Enhace Section, Figure and Table numbering

# Replacement Pull Request

This is the first time I've tried a pull request (and git for that matter), so bear with me...

I've been looking into using respec as a mechanism to replace Microsoft Word for the PCI Express 4.0 Base Specification. That document is currently over 1000 pages and frequently crashes Word. In an effort to understand how respect works, I made a few enhancements.

1. utils.js has a new function appendixMap. It converts a number in to the appropriate appendix string ('A', 'B', 'AA', 'XYZZY', ...). It's recursive, so it should support an infinite number of appendices.

2. `structure.js` now supports use appendixMap and thus can support more than 26 appendices.

3. I enhanced `figures.js` and created `tables.js`. `Figures.js` now takes an optional `conf.figFmt` parameter. If specified, it's a printf-like format that generates the figure number. `Tables.js` is the same, but uses `tot` and `tbl` instead of `tot` and `fig` respectively. Since it's reasonable to have unnumbered tables, tables with no caption don't generate a warning.

4. `conf.figFmt` and `conf.tblFmt` are processed as follows:
`%%` is a single `%`
`%#` is the figure / table number
`%c` is the current chapter / appendix number
`%t` is the `
` or `
`
`%1` says to restart `%#` for every top level section
`%(` starts the figure/table number
`%)` ends the figure/table number . Everything between `%(` and `%)` is wrapped in `` or ``
`conf.figFmt` defaults to `"Fig. %(%#%) %t"` and `conf.tblFmt` defaults to `"%t"`. This means that there should be no change to existing output.

5. I added `examples/basicTables.html` to show off the new features.

6. I updated `aria.js` to label the `#tot` and `#tof` sections properly.