I am looking for a javascript on the fly "Table Of Contents" generation from HTML (with anchors).
Example:
<h1>First level1 heading</h1>
lorem ipsum
<h2>1a heading</h2>
lorem ipsum
<h2>1b heading</h2>
lorem ipsum
<h1>Second level1 heading</h1>
lorem ipsum
Should return something like
First level1 heading
1a heading
1b heading
Second level1 heading
with the lines linked to the headings, and also the orignal html should be returned with anchors inserted.
Is there something included in one of the big javascript libraries or frameworks?
If none of them has, has someone seen a good JS module for this purpose?