$ npm install @mdit-vue/types
Shared types definition of mdit-vue.
npm i @mdit-vue/types
Define a markdown-it plugin with optional typed options:
import type { MarkdownItPlugin } from '@mdit-vue/types';
interface PluginOptions {
breaks?: boolean;
}
const plugin: MarkdownItPlugin<PluginOptions> = (
md,
{ breaks = false } = {},
) => {
md.set({ breaks });
};
Use MarkdownItBlockRule and MarkdownItInlineRule for block and inline parser
rules. Both types are derived from markdown-it's native ruler signatures.
Add more properties to env via TypeScript module augmentation:
import type { Env } from 'markdown-it';
import MarkdownIt from 'markdown-it';
declare module 'markdown-it' {
interface Env {
foo?: string[];
}
}
const md = MarkdownIt({ html: true });
const env: Env = {};
const rendered = md.render('raw markdown text', env);
© 2010 - cnpmjs.org x YWFE | Home | YWFE