It is a program which will add a table of contents into an HTML page.
It will use the headings
</H2>' for heading levels 1 &
2 etc.) in the HTML page as contents markers. The resulting table of contents
will have entries indented according to the level of the heading and the
entries will be linked to relevant sections so readers can jump to them by
clicking in the table of contents.
If it finds a previous table of contents generated by this program then it will be replaced, otherwise a new table of contents will be put at the beginning of the page (from where you can move it to where you prefer and subsequent updates will maintain that position).
You can see the type of table of contents it generates in the following to pages which are trivial page before & after running the program on it.
A Perl interpreter.
To create a table of contents, just run it from a command line with the name (or path relative to the current working directory) of the HTML file to process as its sole parameter.
If the table of contents is not in the place in the HTML document you want
it to be, just open the document in a plain text editor and move whole table of
contents (everything from '
<!--TableOfContents:End-->' inclusive) to where you want
it. Remember to move those two
-->' hidden comments
with the table of contents because that will tell the program where to put the
table of contents when updating it so you won't have to move it again.
To update a table of contents, just run the program as when creating it initially. The program will automatically detect the old table of contents & replace it. Note that HTML is not a page numbered format so there is no need to update the table of contents after editing the HTML unless the headings change.
<A NAME='Section_2.1.4'>' etc.) and the HTML the comments ('
<!--TableOfContentsAnchor:Begin-->' & '
<!--TableOfContentsAnchor:End-->') it puts in don't duplicate existing ones. In the unlikely event of your HTML already using one of these then edit either the HTML or this program to use a different wording.
Download HtmlHeadingsToTableOfContents.pl (6 Kb).
See my computer programs index page for more simple useful computer programs.