Package Exports
- remark-toc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (remark-toc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
remark-toc

Generate a Table of Contents (TOC) for Markdown files with remark.
⚠️ mdast is currently being renamed to remark ⚠️
This means all plug-ins and relating projects change too, causing many changes across the ecosystem. Expect the dust to settle in roughly a day.
See this project at the previous stable commit c4a51d1.
Installation
npm:
npm install remark-toccomponent install wooorm/remark-tocbower install remark-tocDuo:
var toc = require('wooorm/remark-toc');UMD (globals/AMD/CommonJS) (uncompressed and compressed):
<script src="path/to/remark.js"></script>
<script src="path/to/remark-toc.js"></script>
<script>
remark.use(remarkTOC);
</script>Table of Contents
Usage
Require/read dependencies:
var toc = require('remark-toc');
var fs = require('fs');
var remark = require('remark').use(toc);
var readme = fs.readFileSync('readme.md', 'utf-8');Parse markdown (this TOC is the 14th child).
var contents = remark.run(remark.parse(readme)).children[14];Stringify:
var doc = remark.stringify(contents);Yields:
- [Usage](#usage)
- [API](#api)
- [remark.use(toc, options)](#remarkusetoc-options)
- [License](#license)API
remark.use(toc, options)
Adds a Table of Contents to a Markdown document.
Looks for the first heading containing
"Table of Contents","toc", ortable-of-contents(case insensitive, supports alt/title attributes for links and images too);Removes all following contents until an equal or higher heading is found;
Inserts a list representation of the hierarchy of following headings;
Adds links to following headings, using the same slugs as GitHub.
Signatures
remark.use(toc, options?).
Parameters
toc— This plugin;options(Object?) — Settings:slug— Passed toremark-slugheading(string?, default:"toc|table[ -]of[ -]contents?") — Heading to look for, wrapped innew RegExp('^(' + value + ')$', 'i');.maxDepth(number?, default:6) — Maximum heading depth to include in the table of contents, This is inclusive, thus, when set to3, level three headings, are included (those with three hashes,###).tight(boolean?, default:false) — Whether to compile list-items tightly.