Posted by
Toolforger on
Oct 12, 2019; 10:30am
URL: https://discuss.asciidoctor.org/How-do-I-augment-the-ToC-tp7219.html
What I'm really after is chunked output, but this isn't going to happen soon (
pending since 2013 in issue 626) and I need something for a static website that I need to get up within the next four weeks.
Use caseI plan to have a web site with multiple Asciidoctor-generated HTML files.
The pages are grouped. Say, I have a group "blog", and another group "essays", with subgroups such as "essays - computers" and "essays - cats" (the most important subgroups

).
I can imagine that the groups are defined by subdirectory, or by some attributes inside the .adoc files.
The ToC would look differently in each file; e.g. a blog file would have
blog
2019
Looking at asciidoctor ***
Unwrapping ***
Care and feeding ***
Looking at asciidoc
Looking at Hugo
2018
2017
essays
computers
cats
The lines marked *** are supposed to be taken from the normal asciidoctor-generated ToC.
What I already haveI have asciidoctor up and running, generating books and articles in HTML format.
I can do shell scripting, Python and Java programming. (No Ruby, unfortunately.)
Options I considered1. Set up a bunch of include files for the various parts of the ToC. No idea how to integrate that into the predefined toc mechanism of asciidoctor.
2. Build the toc as a standard element of the web pages. Again, use include files so I don't need to write the same ToC lines again and again.
3. Write an extension that collects all the level-0, level-1 ... titles from the various .adoc files, and generates the matching ToC for a given .adoc file. Normally I'd just do this, but I didn't see an easy way to do this in asciidoctorj (most likely because I haven't spent the time to really learn its API yet).
Any advice?Thanks!