Socket
Socket
Sign inDemoInstall

@mdit-vue/plugin-headers

Package Overview
Dependencies
11
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mdit-vue/plugin-headers

A markdown-it plugin to get markdown headers


Version published
Weekly downloads
26K
increased by5.22%
Maintainers
1
Install size
0.997 MB
Created
Weekly downloads
 

Changelog

Source

1.0.0 (2023-09-26)

Bug Fixes

  • plugin-toc: remove duplicate itemClass (#7) (7e0f1f0)

BREAKING CHANGES

  • drop support for node 16

Readme

Source

@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 MarkdownIt from 'markdown-it';
import { headersPlugin } from '@mdit-vue/plugin-headers';
import type { MarkdownItEnv } from '@mdit-vue/types';

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.

Keywords

FAQs

Last updated on 26 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc