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

0.0.3 • Public • Published

html2toc

Part of @plumbiu/md.

Feature

  • Tiny
  • Fast
  • Well tested

Usage

/*
  function html2Toc(html: string, options?: {
    depth: number
  }): {
    level: number
    content: string
    hash: string
  }[]
*/

import { md2html } from '@plumbiu/md'

await md2toc('<h1 id="hello-world">hello world</h1>', {
  // depth mean the toc depth
  depth: 3 // 3 by default
})

/*
  [
    { level: 1, content: 'hello world', hash: 'hello-world' }
  ]
*/

Readme

Keywords

Package Sidebar

Install

npm i html2toc

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

6.92 kB

Total Files

9

Last publish

Collaborators

  • plumbiu