Inserting toc entries from hyperlinked source code

Posted by daveb on
URL: https://discuss.asciidoctor.org/Inserting-toc-entries-from-hyperlinked-source-code-tp668.html

Great progress on Asciidoctor - well done.

I have some html that is auto generated and it has headings I want to include in the toc.  I see I can insert suitable html in to the toc section as a post process extension but is there a better/alternative way of achieving this?

The auto generated html is a source listing and I want to include the function names in the toc.  In addition to updating the toc I will need to add anchors to the function names and I would also like to have the function calls hyperlinked to the function definitions as well.  I am still considering the best way to do this and I think my options are:
       
1. Use a syntax highlighter (coderay or rouge) to generate the html then using the known list of functions edit the html to add in the anchor markup.  This could be done as an asciidoctor extension or standalone process and just use a passthrough include.

2. Extend coderay or rouge to do this linking as part of its syntax highlighting.

3. Post process the html asciidoctor generates either as a post process extension or as an additional step in my doc build process.

Any input welcome.

Dave.