If a line is toc
it will be replaced with a table of contents
So if a markdown document contains the following:
# Title
toc
## Heading 1
Text1
## Heading 1
Text2
The result will be rendered:
# Title
<!-- toc -->
## Contents
* [Heading 1](#heading-1)
* [Heading 2](#heading-2)
<!-- endToc -->
## Heading 1
Text1
## Heading 2
Text2
Headings with level 2 (##
) or greater can be rendered. By default all level 2 and level 3 headings are included.
To include more levels use the --toc-level
argument. So for example to include headings levels 2 though level 6 use:
mdsnippets --toc-level 5
To exclude headings use the --toc-excludes
argument. So for example to exclude heading1
and heading2
use:
mdsnippets --toc-excludes heading1:heading2