I’m considering writing a filter that inserts chapter TOCs via
\ChapterTOC:
INPUT (# is for parts, ## is for chapters, etc.):
## Chapter on animals {#animals}
### Section on dogs {#dogs}
#### Subsection on poodles
### Section on cats {#cats}
CHAPTER TOC (number of chapter is 12):
* 12.1. [Section on dogs](#dogs)
* 12.1.2. Subsection on poodles
* 12.2. [Section on cats](#cats)
Considerations:
- Getting the numbering right is challenging – AFAICT, a filter does not have access to the numbers and numbering works differently for LaTeX and HTML. Thus, I’ll probably extend my filter that numbers text units for HTML, to additionally create TOCs (for LaTeX, it would only do the latter): https://groups.google.com/d/topic/pandoc-discuss/N4Qv0Bvgt_E/discussion
- Alternatively, things would be easier if one omitted the chapter number. But then the numbers in the TOC are not as nice.
- For another book, where I couldn’t change how Markdown was translated to HTML, PDF, etc., I wrote a shell script that inserted the chapter TOC into the text file. For pandoc, I’d prefer to use a filter. The output of the shell script looks as follows: http://exploringjs.com/es6/ch_symbols.html
- The shell script complains if sections don’t have IDs. I’ll have to look into retrieving pandoc’s auto-generated IDs.
Is there something I’m overlooking? Any tips or suggestions?