http://qs321.pair.com?node_id=270569

John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

Many years ago, I wrote a small Perl program that scans a hand-written HTML file and generates/updates a table of contents at the top of the file, with links to the various H\d tags.

That was fairly crude, being line-oriented and required that the header tags and matching names be just so. But it did recognise the stuff it generated before and replaced it with a refreshed copy.

I'd like something modern that does this. A proper HTML parser would take any HTML without relying on special formatting conventions or restrictions. The generated table of contents can have fancy dynamic-expanding/collapsing features.

Someone has got to have done this already! Where can I find it?

—John