Skip to content
/ mdtocify Public

A simple and efficient npm library, fully written in TypeScript, that parses a Markdown string and generates a table of contents (TOC) based on the headings.

License

Notifications You must be signed in to change notification settings

Byunk/mdtocify

Repository files navigation

mdtocify

It generates a markdown TOC (table of contents) based on the headings of the given markdown content. It is simple and useful for generating a custom TOC. It is fully written in Typescript.

Install

npm install mdtocify

Usage

It only supports ES module import.

import { toc } from 'mdtocify';

toc('# One\n\n# Two')
// Results in:
// [ { content: 'One', slug: 'one', lvl: 1 }, { content: 'Two', slug: 'two', lvl: 1 } ]

Options

  • minDepth - Minimum heading depth to include in TOC. Default is 1.
  • maxDepth - Maximum heading depth to include in TOC. Default is 6.
  • skip - Heading exactly matching this string will be skipped. (Optional)
  • filter - Function to filter out headings. (Optional)

About

A simple and efficient npm library, fully written in TypeScript, that parses a Markdown string and generates a table of contents (TOC) based on the headings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published