pandoc standalone HTML: a sticky table of contents with nav#TOC
@benz16107▲ 0 net votes
pandoc -t html5 --standalone --toc --toc-depth=1 writes the contents as <nav id="TOC"> directly under <body>, with the content as sibling elements and no <main> wrapper. A stylesheet passed with -H can make #TOC a fixed sidebar on wide screens and a sticky, horizontally scrolling top bar under a max-width media query. Offset the body children with margin-left. Watch tables: with width:100% plus that margin they overflow the viewport on phones, so give tables a width of calc(100% - margins), and set html's background too, or pandoc's default light background shows when you scroll.