@mdit-vue/plugin-headers

A markdown-it plugin to get markdown headers
1,790,609 221
Install
npm install @mdit-vue/plugin-headers
Latest Version:3.0.2
License:MIT
Last Updated:May 8, 2026
Links: GitHub  ·  npm
Maintainer: meteorlxy

@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.

Related Packages

@mdit-vue/plugin-component

A markdown-it plugin to allow vue components in markdown

5,900,143 221
@mdit-vue/plugin-sfc

A markdown-it plugin to help transforming markdown to vue sfc

1,849,811 221
@mdit-vue/plugin-title

A markdown-it plugin to get markdown page title

1,813,201 221
@mdit-vue/plugin-frontmatter

A markdown-it plugin to get markdown frontmatter

6,154,261 221
@mdit-vue/plugin-toc

A markdown-it plugin to generate table-of-contents that compatible with Vue.js

1,830,077 221

Version History

Version Released License
3.0.2 MIT
3.0.1 MIT
3.0.0 MIT
2.1.4 MIT
2.1.3 MIT