vite-plugin-marked
v0.1.0
Published
A minimalist Vite plugin for converting Markdown to HTML with [marked](https://github.com/markedjs/marked). No other dependencies.
Readme
vite-plugin-marked
A minimalist Vite plugin for converting Markdown to HTML with marked. No other dependencies.
pnpm add vite-plugin-marked -DUsage
import markedPlugin from 'vite-plugin-marked'
export default defineConfig({
plugins: [
// Default options
markedPlugin({
htmlQuery: false,
// Marked options
async: false,
breaks: false,
extensions: null,
gfm: true,
hooks: null,
pedantic: false,
renderer: null,
silent: false,
tokenizer: null,
walkTokens: null,
}),
],
})The options for marked are documented here.
By default, any .md import will be processed into a default export containing the HTML string.
import htmlString from './example.md'
console.log(htmlString)Note that any .md imports with ?raw or other query params won't get processed by this plugin.
?html query
You can set the htmlQuery option to true to only process .md imports with the ?html query.
import htmlString from './example.md?html'