This package has been deprecated

Author message:

WARNING: This package is no longer maintained. Please install remark-extract-toc instead.

remark-contents
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

remark-contents

remark plugin to extract table of contents.

This plugin extracts only Heading from mdast markdown, then converts them to a nested List keeping the depth.

Install

npm install remark-contents

Usage

var unified = require("unified");
var markdown = require("remark-parse");
var remark2rehype = require("remark-rehype");
var html = require("rehype-stringify");
var contents = require("remark-contents");

var fs = require("fs");
var text = fs.readFileSync("example.md", "utf8");

unified()
  .use(markdown, { commonmark: true })
  .use(contents)
  .use(remark2rehype)
  .use(html)
  .process(text);

This example.md

# Alpha

aaaa

## Bravo

bbbb

### Charlie

cccc

## Delta

dddd

will be converted by this library like...

-   [Alpha](#alpha)

    -   [Bravo](#bravo)

        -   [Charlie](#charlie)

    -   [Delta](#delta)

License

MIT

Package Sidebar

Install

npm i remark-contents

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

4.88 kB

Total Files

6

Last publish

Collaborators

  • inokawa