A remark plugin to selectively add a table of contents and configure it for each markdown file. Ported and updated from gatsby-remark-table-of-contents
.
<!--
👇 This code block gets replaced
with a TOC of h2 headings only
-->
```toc
from: 1
to: 2
```
This package is ESM only. In Node.js (version 16.0+, or 18.0+), install with npm:
npm install remark-selective-toc
- You need more specific control over the TOC, such as excluding certain heading levels.
- You're working with multiple markdown files that each require different TOC configurations
- Some of your markdown files don't warrant a TOC at all.
- Type:
number
- Default:
2
Sets the minimum heading depth to include.
- Type:
number
- Default:
6
Sets the maximum heading depth to include.
- Type:
string
- Default:
toc
Sets the class name of the div wrapping your table of contents.
- Type:
boolean
- Default:
false
tight
lets you specify whether or not you want spaces before and between the list items.
<!-- tight: true -->
- [Here's an h2](#heres-an-h2)
- [Another h2](#another-h2)
- [and H3](#and-h3)
<!-- tight: false -->
- [Here's an h2](#heres-an-h2)
- [Another h2](#another-h2)
- [and H3](#and-h3)
- Type:
string
orarray
- Default:
''
Excludes titles matching this regex pattern.
- Type:
boolean
- Default:
false
Chooses between ordered and unordered list.
tight
is true by default- The Gatsby plugin uses
from-heading
andto-heading
as options. This plugins accepts both these values as well as justfrom
andto
.
Feel free to open issues and pull requests.
MIT License. See LICENSE
for more information.