# @okmarvin/markdown-it-toc

> markdown-it plugin for adding table of contents

Latest version **0.0.21** (published 2019-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @okmarvin/markdown-it-toc
pnpm add @okmarvin/markdown-it-toc
yarn add @okmarvin/markdown-it-toc
bun add @okmarvin/markdown-it-toc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.21 |
| Published | 2019-07-18 |
| First published | 2018-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sam Chen |
| Maintainers | chenxsan |
| Keywords | markdown-it, markdown-it-plugin, table-of-contents, toc |

## Links

- npm: https://www.npmjs.com/package/@okmarvin/markdown-it-toc
- npm.io page: https://npm.io/package/@okmarvin/markdown-it-toc

## Dependencies (3)

- [clone](https://npm.io/package/clone.md) ^2.1.1
- [innertext](https://npm.io/package/innertext.md) ^1.0.3
- [github-slugger](https://npm.io/package/github-slugger.md) ^1.2.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.0.21 (latest) — 2019-07-18
- 0.0.20 — 2019-01-30
- 0.0.19 — 2019-01-12
- 0.0.18 — 2018-12-24
- 0.0.17 — 2018-12-20
- 0.0.13 — 2018-08-02

## README

## Why another markdown-it table of contents plugin?

Most of the table of contents plugins for markdown-it out there wrap toc in `<p></p>`, i.e. they are inlined. When you have `ul` tag inside `p`, browsers would render it as:

```html
<p></p>
<ol></ol>
<p></p>
```
It's ugly.

In `@okmarvin/markdown-it-toc`, it will be wrapped in a `nav`:

```html
<nav class="toc">
<h2 class="toc__heading">Table of contents</h2>
<ol></ol>
</nav>
```

## Usage

```js
var md = require('markdown-it')({
  html: true,
  linkify: true,
  typography: true
}).use(require('@okmarvin/markdown-it-toc'))
md.render('{:toc}\n# heading one')
```
Remember to add placeholder `{:toc}` to where you want table of contents be inserted in your markdown file.

## Options

You can specify options too:

|Name|Description|Default|
|---|---|---|
|class|css class for table of contents' container|`toc`|
|hMin|minimum heading level toc will show|1|
|hMax|maximun heading level toc will show|6|
|enableHeadingIcon|add an icon to heading anchor|`false`|
|headingAnchorClass|class for heading anchor|`anchor`|
|headingAnchorPrefix|prefix for heading anchor|``|
|title|Heading|`Table of contents`|

---
_Source: https://npm.io/package/@okmarvin/markdown-it-toc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
