Prettier Plugin for Slidev
raw JSON → 1.0.5 verified Sat Apr 25 auth: no javascript
A Prettier plugin that formats Slidev markdown slides (slides.md, pages/*.md). Current stable version is 1.0.5, released as part of the official Slidev ecosystem. It uses a custom 'slidev' parser to handle Slidev-specific frontmatter, slide separators (---), and code block annotations. The plugin is released with the Slidev ecosystem, following minor version bumps as Slidev evolves. Key differentiator: it is the only dedicated formatter for Slidev slide files, ensuring consistent formatting for Slidev's markdown syntax without breaking slide structure.
Common errors
error Cannot find module 'prettier-plugin-slidev' ↓
cause The plugin is not installed or not in the same node_modules as Prettier (global vs local).
fix
Install as a dev dependency: npm i -D prettier prettier-plugin-slidev
error Unexpected token '-' in file slides.md ↓
cause Prettier is using the 'markdown' parser instead of 'slidev' parser, causing it to choke on Slidev-specific syntax like frontmatter '---' or slide separators.
fix
Add the override with parser: 'slidev' as shown in the configuration.
error Invalid configuration file: plugins must be a string or an array of strings ↓
cause Using require() to load the plugin in the config file, but Prettier expects plugin names as strings.
fix
Set plugins to ["prettier-plugin-slidev"] in the config (JSON or YAML).
Warnings
gotcha The plugin only works with Prettier v3.2.4 or later. ↓
fix Upgrade Prettier to ^3.2.4
gotcha Only files named 'slides.md' or in 'pages/*.md' are recognized as Slidev files by default. ↓
fix Adjust the 'files' glob in the override if you use different file names.
gotcha Simply adding the plugin to 'plugins' without specifying 'parser: "slidev"' will not work because .md files default to the markdown parser. ↓
fix Always include 'parser: "slidev"' in the override options.
gotcha Do not use this plugin with other Prettier markdown plugins (e.g., prettier-plugin-md) as they may conflict. ↓
fix Remove other markdown-related Prettier plugins when using this one.
Install
npm install prettier-plugin-slidev yarn add prettier-plugin-slidev pnpm add prettier-plugin-slidev Imports
- plugin wrong
// Wrong: using require('prettier-plugin-slidev') in JS config module.exports = { plugins: [require('prettier-plugin-slidev')] }correct// Prettier config overrides { "files": ["slides.md", "pages/*.md"], "options": { "parser": "slidev", "plugins": ["prettier-plugin-slidev"] } }
Quickstart
npm i -D prettier prettier-plugin-slidev
# .prettierrc.json
{
"overrides": [
{
"files": ["slides.md", "pages/*.md"],
"options": {
"parser": "slidev",
"plugins": ["prettier-plugin-slidev"]
}
}
]
}
# Then run:
npx prettier --write slides.md