2.1.2 • Published 19 days ago

@mdit-vue/plugin-headers v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

@mdit-vue/plugin-headers

npm license

A markdown-it plugin to get markdown headers.

  • Extracts all headers info into markdown-it env.headers.

Install

npm i @mdit-vue/plugin-headers

Usage

import { headersPlugin } from '@mdit-vue/plugin-headers';
import type { MarkdownItEnv } from '@mdit-vue/types';
import MarkdownIt from 'markdown-it';

const md = MarkdownIt({ html: true }).use(headersPlugin, {
  // options
});
const env: MarkdownItEnv = {};

const rendered = md.render(
  `\
# h1
## h2
### h3
`,
  env,
);

console.log(env.headers);

Options

format

  • Type: (str: string) => string

  • Details:

    A function for formatting header title.

level

  • Type: number[]

  • Default: [2, 3]

  • Details:

    Heading level that going to be extracted.

    When using this plugin with markdown-it-anchor (recommended), this option should be a subset of markdown-it-anchor's level option to ensure the header slugs are existed.

shouldAllowNested

  • Type: boolean

  • Default: false

  • Details:

    Should allow headers inside nested blocks or not.

    If set to true, headers inside blockquote, list, etc. would also be extracted.

slugify

  • Type: (str: string) => string

  • Default: slugify from @mdit-vue/shared

  • Details:

    A custom slugification function.

    The default slugify function comes from @mdit-vue/shared package.

    When using this plugin with markdown-it-anchor (recommended), this option will be ignored because the id of the headings have already been determined by markdown-it-anchor's slugify option.

2.1.2

19 days ago

2.1.0

26 days ago

2.0.0

5 months ago

1.0.0

7 months ago

0.12.1

8 months ago

0.12.0

1 year ago

0.11.2

1 year ago

0.9.3

2 years ago

0.10.0

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago