Détail du package

@mdit-vue/plugin-component

mdit-vue235.5kMIT3.0.2

A markdown-it plugin to allow vue components in markdown

markdown-it, markdown-it-plugin, vue, component

readme

@mdit-vue/plugin-component

npm license

A markdown-it plugin to allow Vue components in markdown.

  • Treats vue built-in components and unknown HTML tags as vue components (markdown-it would treat them as inline tags by default).
  • Allows vue @ directive on native HTML tags.

Install

npm i @mdit-vue/plugin-component

Usage

This plugin will only take effects when the html option of markdown-it is enabled:

import { componentPlugin } from '@mdit-vue/plugin-component';
import MarkdownIt from 'markdown-it';

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

const rendered = md.render(
  `\
<!-- @ shorthand is supported -->
<Foo @click="onClick" />

<!-- multi-line syntax won't be wrapped with <p> -->
<Foo
  class="foo"
  :bar="bar"
/>
`,
);

Options

blockTags

  • Type: string[]

  • Default: []

  • Details:

    Extra tags to be treated as block tags.

    By default, all standard HTML inline elements will be treated as inline tags (excluding Vue built-in special elements). All unknown elements will be assumed as Vue components, and will be treated as block tags (with slight differences).

    In some cases (should be rare though) you might want to force some tags to behave like block tags, then you can use this option to specify the tag names.

    Notice that this option is case-sensitive, and has higher priority than the inlineTags option.

inlineTags

  • Type: string[]

  • Default: []

  • Details:

    Extra tags to be treated as inline tags.

    By default, only standard HTML inline elements will be treated as inline tags (excluding Vue built-in special elements). All unknown elements will be assumed as Vue components, and will be treated as block tags (with slight differences).

    Treating Vue components like block tags would work as expected in most cases. However, in some cases you might want to force some tags to behave like inline tags, then you can use this option to specify the tag names.

    Notice that this option is case-sensitive, and has lower priority than the blockTags option.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.0.2 (2025-08-11)

Bug Fixes

  • plugin-title: avoid output types being tree-shaken (6255fd4)

3.0.1 (2025-08-11)

Note: Version bump only for package @mdit-vue/monorepo

3.0.0 (2025-08-11)

Build System

BREAKING CHANGES

  • drop node 18 and migrate to pure ESM packages

2.1.4 (2025-04-10)

Bug Fixes

  • plugin-frontmatter: extract frontmatter in parse step (close #13) (#14) (1192bd2)

2.1.3 (2024-05-13)

Note: Version bump only for package @mdit-vue/monorepo

2.1.2 (2024-04-15)

Bug Fixes

  • sync markdown-it types updates (#9) (f6768b1)

2.1.1 (2024-04-13)

Bug Fixes

  • plugin-component: inline html block tags to make cjs build work (eb1a264)

2.1.0 (2024-04-08)

Features

  • upgrade markdown-it types to v14 (6839be8)

2.0.0 (2023-12-08)

Features

BREAKING CHANGES

  • bump to markdown-it 14

1.0.0 (2023-09-26)

Bug Fixes

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

BREAKING CHANGES

  • drop support for node 16

0.12.1 (2023-08-24)

Note: Version bump only for package mdit-vue

0.12.0 (2023-02-10)

Features

  • plugin-headers: add shouldAllowNested option (93e004d)
  • plugin-toc: add shouldAllowNested option (close #5) (1f3b867)
  • shared: add shouldAllowNested option for resolveHeadersFromTokens (9363b92)

0.11.2 (2022-12-23)

Bug Fixes

  • shared: avoid resolve headers in nested blocks (ce146bd)

0.11.1 (2022-08-30)

Note: Version bump only for package mdit-vue

0.11.0 (2022-08-25)

Features

  • plugin-sfc: extract all script blocks (8c39df6)

0.10.0 (2022-08-23)

Features

  • plugin-headers: resolve link property for headers (da2954f)
  • types: add link property to header (7461417)

0.9.4 (2022-08-23)

Bug Fixes

  • plugin-component: handle multiline component tags correctly (53724fa)

0.9.3 (2022-08-20)

Bug Fixes

  • plugin-headers: avoid headers being overridden by another rendering (de1030b)
  • plugin-title: avoid title being overridden by another rendering (43cc020)

0.9.2 (2022-08-18)

Bug Fixes

  • plugin-toc: avoid toc being overridden by another rendering (c145c26)

0.9.1 (2022-07-26)

Bug Fixes

  • plugin-sfc: expose MarkdownSfcBlocks type (c2a91de)

0.9.0 (2022-07-26)

Features

  • plugin-sfc: extract SFC blocks as structured data (5a0aa54)

BREAKING CHANGES

  • plugin-sfc: the type of env.sfcBlocks has been changed

0.8.1 (2022-07-22)

Bug Fixes

  • plugin-component: make component tags behave like inline tags in some cases (9db6f9c)

0.8.0 (2022-07-22)

Features

  • plugin-component: add blockTags and inlineTags options (4651422)

0.7.1 (2022-07-20)

Note: Version bump only for package mdit-vue

0.7.0 (2022-07-18)

Features

  • plugin-frontmatter: extract content without frontmatter into env.content (a9d5cef)

0.6.0 (2022-07-11)

Features

  • types: extract types from shared package (5fc56ce)

0.5.0 (2022-07-06)

Features

  • plugin-frontmatter: add frontmatter plugin (bcffc7a)

0.4.0 (2022-07-02)

Features

  • plugin-headers: add headers plugin (636aa9b)
  • plugin-title: add title plugin (662e153)

0.3.1 (2022-06-25)

Bug Fixes

  • plugin-toc: export types (310320e)

0.3.0 (2022-06-25)

Features

  • plugin-toc: add toc plugin (e64cc2c)
  • shared: add html escape and unescape utils (e1103c2)

0.2.0 (2022-06-23)

Features

  • plugin-sfc: add sfc plugin (1eb4e0a)
  • shared: add shared package (9e36bdc)

0.1.1 (2022-06-23)

Bug Fixes

  • plugin-component: add js extension to work with esm (42ccdad)

0.1.0 (2022-06-22)

Features

  • plugin-component: add component plugin (cd2eeaa)