markdown-it-code-snippet
v0.0.1
Published
the code snippet include plugin for markdown-it.
Maintainers
Readme
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
USED
pnpm add -D markdown-it-code-snippetimport codeSnippet from 'markdown-it-code-snippet'
md.use(codeSnippet)OPTIONS
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
}SYNTAX
<<< snippets/playground.ts
<<< ~/snippets/playground.ts
<!--
include all contents of the file.
`~` needs to be set to a custom resolution path in `resolvePath`.
-->
<<< snippets/playground.ts#snippet
<<< snippets/playground.ts#snippet1,snippet2
<!-- include the contents of the `snippet` region -->
<<< snippets/playground.ts#snippet{1,3}
<!--
that's right.
but `<<< snippets/playground.ts{1,3}#snippet` is not allowed.
-->/* #start region */ | /* # start region */
/* #end */
// `#start region` and `#end` should be enclosed in comments.