Table of contents
sgbotsford at gmail.com
Thu Mar 5 09:58:28 EST 2009
Tables of contents should be generated automatically. Maintaining
them by hand especially with electronic documents that are shall we
say, a bit unstable, is truly a PITA
FrameMaker had (may still have) a feature in which you could abstract
the content of styles from your document, and apply a different style
to use them in a TOC.
E.g. (Adapting language a bit here for the web world) You could
extract H1 through H6, stuff them in a file. Then you apply an
appropriate CSS to them to make a reasonable looking TOC.
Two approaches occur to me:
1. Put a label above headline. Context grep for lines in your
markdown files that start with #. Use 1 line of previous context.
Perl script turns the label plus the filename into a markdown URL link.
grep -r -B1 "^#" tt2
tt2/Advice/Design/Landscaping.tt2:# Planning for Change
tt2/Advice/Design/Landscaping.tt2:## Gee, Those Little Trees Look Silly
tt2/Advice/Design/Design_Principles.tt2:# Principles of Design.
tt2/Advice/Design/Design_Principles.tt2:## Basic principles.
You'll note that I was being clever and cute and used headlines to do
something stylistic. My Bad.
Approaches you could take for this:
* Only index headlines that have a label on them.
* multiple successive headlines are glommed together for indexing. If
the secondary heads are in different size, then they are shown in
The otehr approach is to look for the label, then take the line
immediately following that. If you are consistent, you would be able
to pull lists of figures, photos, tables and equations from your
documents this way.
Warburg, Alberta T0C 2T0
More information about the Markdown-Discuss