@mdit-vue/plugin-sfc
@mdit-vue/plugin-sfc
A markdown-it plugin to help transforming markdown to Vue SFC.
- Avoids rendering
<script>and<style>tags and extract them into to markdown-itenv.sfcBlocks. - Supports extracting custom blocks.
- Provides
env.sfcBlocks.templatefor convenience.
Install
npm i @mdit-vue/plugin-sfc
Usage
This plugin will only take effects when the html option of markdown-it is enabled:
import { sfcPlugin } from '@mdit-vue/plugin-sfc';
import type { MarkdownItEnv } from '@mdit-vue/types';
import MarkdownIt from 'markdown-it';
const md = MarkdownIt({ html: true }).use(sfcPlugin, {
// options
});
const env: MarkdownItEnv = {};
const rendered = md.render(
`\
# foo
<script>
console.log('bar')
</script>
`,
env,
);
console.log(env.sfcBlocks);
Options
customBlocks
-
Type:
string[] -
Default:
[] -
Details:
SFC custom blocks to be extracted.
By default, only
<script>and<style>tags will be extracted. You can set this option to support SFC custom blocks in markdown.For example, if you set this option to
['i18n'], the<i18n>tag in your markdown content will be extracted toenv.sfcBlocks.customBlocksand won't appear in the rendered result.
Related Packages
markdown-it-sfc-tabs-snippet
Markdown-it plugin to display Vue Single File Component as tabs snippets in mark...
260
0
@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 | |
| 2.1.2 | MIT | |
| 2.1.0 | MIT | |
| 2.0.0 | MIT | |
| 1.0.0 | MIT | |
| 0.12.1 | MIT | |
| 0.12.0 | MIT | |
| 0.11.1 | MIT | |
| 0.11.0 | MIT | |
| 0.10.0 | MIT | |
| 0.9.2 | MIT | |
| 0.9.1 | MIT | |
| 0.9.0 | MIT | |
| 0.8.0 | MIT | |
| 0.7.1 | MIT | |
| 0.7.0 | MIT | |
| 0.6.0 | MIT | |
| 0.5.0 | MIT | |
| 0.4.0 | MIT | |
| 0.3.0 | MIT | |
| 0.2.0 | MIT |