http://www.perlmonks.org?node_id=1202473


in reply to TOCs and deeplinks for our house rules

This would be a very good idea.

In case it might be helpful, years ago, I wrote a Perl program to add TOCs to HTML. If I can find it, I will post it under CUFP.

The program looks for header elements (<h1> through <h6>) and checks them for an id attribute. If there isn't one, it adds one, using a generated identifier. The text of the header elements is used for the TOC entries, which are dt elements in a dl list element. I did not implement nesting of dl lists.