9

How to generate table of contents with links for GitHub markdown with pandoc?

I tried pandoc -f markdown_github --toc -s -S README.md -o new.md It does create a table of contents but it has no link to sections.

I'm trying to generate a table of contents such as:

enter image description here

on a Windows machine.

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400

1 Answers1

12

Try the following command:

pandoc -f gfm --toc -s README.md -o r.md

as it worked fine for me with the latest version of pandoc.

With pandoc's own README.md, I got this ToC:

-   [Pandoc](#pandoc)
    -   [The universal markup
        converter](#the-universal-markup-converter)
    -   [Installing](#installing)
    -   [Documentation](#documentation)
    -   [Contributing](#contributing)
    -   [License](#license)
kenorb
  • 26,615