the code snippet include plugin for markdown-it.
npm install markdown-it-code-snippet> My own plugin, may crash at any time.
> You can view the plugin effect at https://naiheyoung.github.io/markdown-it-code-snippet
``bash`
pnpm add -D markdown-it-code-snippet
`ts
import codeSnippet from 'markdown-it-code-snippet'
md.use(codeSnippet)
`
`ts
interface CodeSnippetOptions {
/*
the snippets be separated by line breaks
default: true
*/
snippetsBreak?: boolean
/*
when multiple regions are present, each snippet will be separated by a line break.
default: true
*/
repeatedSnippetBreak?: boolean
/*
resolve file path
filePath: the file path written in md.`
default: project root directory.
e.g. <<< snippets/playground.ts
filePath will be snippets/playground.ts
*/
resolvePath?: (filePath: string) => string
}
`md
<<< snippets/playground.ts
<<< ~/snippets/playground.ts
<<< snippets/playground.ts#snippet
<<< snippets/playground.ts#snippet1,snippet2
<<< snippets/playground.ts#snippet{1,3}
`
`ts
/ #start region / | / # start region /
/ #end /
// #start region and #end should be enclosed in comments.``