Socket
Socket
Sign inDemoInstall

@mdit-vue/plugin-sfc

Package Overview
Dependencies
10
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mdit-vue/plugin-sfc

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


Version published
Weekly downloads
26K
increased by4.7%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.9.2 (2022-08-18)

Bug Fixes

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

Readme

Source

@mdit-vue/plugin-sfc

npm license

A markdown-it plugin to help transforming markdown to Vue SFC.

  • Avoids rendering <script> and <style> tags and extract them into to markdown-it env.sfcBlocks.
  • Supports extracting custom blocks.
  • Provides env.sfcBlocks.template for 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 MarkdownIt from 'markdown-it';
import { sfcPlugin } from '@mdit-vue/plugin-sfc';
import type { MarkdownItEnv } from '@mdit-vue/types';

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 to env.sfcBlocks.customBlocks and won't appear in the rendered result.

Keywords

FAQs

Last updated on 18 Aug 2022

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