Fossil Forum

Best practice for Table of Contents in documentation pages / wikis
Login

Best practice for Table of Contents in documentation pages / wikis

Best practice for Table of Contents in documentation pages / wikis

(1) By smartmic on 2022-01-26 11:28:26 [link] [source]

I saw that the efforts to enable header IDs for markdown content have been stopped but I am a bit lost with the comment "… summary: we should do it like pandoc does".

Is my understanding correct that fossil's internal markdown renderer does not support header IDs, if I want them for my embedded documentation, I would to have to check in already compiled HTML docs which includes the IDs & table of contents? In other words, I cannot use fossil markdown but have to do the HTML rendering outside fossil. The main disadvantage here is that I have to keep both markdown source and HTML output in the repository.

Did I miss something or are there any better practices for including ToCs in embedded documentation (or wiki pages)?

(2) By Stephan Beal (stephan) on 2022-01-26 12:04:21 in reply to 1 [link] [source]

Is my understanding correct that fossil's internal markdown renderer does not support header IDs, if I want them for my embedded documentation, I would to have to check in already compiled HTML docs which includes the IDs & table of contents?

You do not have to pre-compile the wiki to HTML but you do have to add the anchors and TOC manually. Here's an example:

https://fossil.wanderinghorse.net/r/cwal/info?name=7be761e7448368ae44536cdd6fbe835e1dc83b9c&txt=1

I saw that the efforts to enable header IDs for markdown content have been stopped but I am a bit lost with the comment "… summary: we should do it like pandoc does".

It turns out that dynamically generating headers is far more complicated and nuanced than i initially hoped for when starting that defunct branch. The overall consensus of the linked discussion was essentially that if we're doing to do it right, we should follow pandoc's example. So far nobody has stepped up to implement that, though.

The part of that thread which diverged into pandoc starts at 9d5974ea863904de.

Did I miss something or are there any better practices for including ToCs in embedded documentation (or wiki pages)?

Currently they have to be added by hand, generated via client-provided code before checking in the documents, or generated via client-provided JS code which gets loaded with the site's skin and runs automatically for paths which can render embedded docs. In my own docs they're hand-crafted (like the example lined to above).

(3) By smartmic on 2022-01-26 15:39:28 in reply to 2 [source]

Thanks, Stephan, your example is helpful.

Currently they have to be added by hand, generated via client-provided code before checking in the documents,

Just sharing my quickly drafted oneliner (works only with GNU sed) which should do the trick then:

echo "## This is any headline" | sed 's/^\(#\+ \(.*\)\)/<a id="\L\2\E"><\/a>\n\1/' | sed '/<a id="/s/[ -]//2g'