https://github.com/aleclarson/vite-plugin-marked
The simplest Markdown-to-HTML plugin for Vite
https://github.com/aleclarson/vite-plugin-marked
Last synced: about 1 year ago
JSON representation
The simplest Markdown-to-HTML plugin for Vite
- Host: GitHub
- URL: https://github.com/aleclarson/vite-plugin-marked
- Owner: aleclarson
- License: mit
- Created: 2025-03-15T16:54:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-15T17:07:12.000Z (over 1 year ago)
- Last Synced: 2025-04-16T02:59:47.182Z (about 1 year ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-marked
A minimalist Vite plugin for converting Markdown to HTML with [marked](https://github.com/markedjs/marked). No other dependencies.
```
pnpm add vite-plugin-marked -D
```
## Usage
```ts
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](https://marked.js.org/using_advanced#options).
By default, any `.md` import will be processed into a default export containing the HTML string.
```ts
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.
```ts
import htmlString from './example.md?html'
```