1.0.0 • Published 6 years ago

remark-outer-toc v1.0.0

Weekly downloads
11
License
ISC
Repository
github
Last release
6 years ago

Outer TOC

I came across the problem needing to get the output of generating a toc out of Remark so that I could create my own TOC. This plugin does just that!

Usage

const slug = require('remark-slug');
const outsideToc = require('remark-outside-toc');

const md = remark()
    .use(slug)
    .use(outsideToc, {
        callback: (headers) => { console.log(headers) }, // Callback function outside-toc will use to give back the headers found
        id: true, // Flag to decide if you want outside-toc to grab id's from the headers, requires there to be id's by using another plugin like slug or handwritten html tags with id's
        depth: 3 // The depth of headers you want to add to TOC, this will grab h1, h2, and h3
    })
    .processSync(content);