pandoc input.md --toc -s -o output.html

Category: Media & Conversion

pandoc input.md --toc -s -o output.html

Add a table of contents to HTML output

Adds a table of contents at the top of the HTML, generated from the headings. --toc needs standalone output, hence the -s. Use --toc-depth=2 to limit the nesting.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.