Registry / devops / prettier-plugin-vitepress

prettier-plugin-vitepress

JSON →
library0.0.10jsnpmunverified

Prettier plugin to format Vue in Markdown syntax used in VitePress and VuePress. Current stable version 0.0.10 (release cadence: irregular, maintained by brc-dd). Key differentiators: specifically targets Vue SFCs embedded in Markdown (e.g., `<script setup>`, `<template>`, `<style>`) within VitePress/VuePress projects, leveraging Prettier's plugin system to parse and reformat Vue-like content without interfering with standard Markdown formatting. Only peer dependency is Prettier ^3.5.3. Ships TypeScript types.

npm install prettier-plugin-vitepress
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-VI
P
prettier-plugin-vitepress
devopsjavascriptv0.0.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
plugins: [require.resolve('prettier-plugin-vitepress')]
In .prettierrc, use require.resolve to resolve path correctly.
prettier-plugin-vitepress
plugins: ['prettier-plugin-vitepress']
Simpler form; Prettier resolves plugin by name if installed.
prettier-plugin-vitepress
// Not imported as a JS module directly; use config file
The plugin is not typically imported in code, only referenced in Prettier config.

Install plugin, configure .prettierrc, and see Vue SFC formatting inside Markdown.

// Install npm add -D prettier prettier-plugin-vitepress // .prettierrc { "plugins": ["prettier-plugin-vitepress"] } // Example file: example.md // Original: # Hello <script setup> import {ref} from 'vue'; const count=ref(0) </script> <template> <div>{{ count }}</div> </template> <style scoped> div{color:red} </style> // After `npx prettier --write example.md`: # Hello <script setup> import { ref } from 'vue' const count = ref(0) </script> <template> <div>{{ count }}</div> </template> <style scoped> div { color: red; } </style>
Debug
Known issues
gotchaPlugin only formats Vue content inside Markdown fenced blocks; standard Markdown formatting is handled by Prettier's Markdown parser.
fix
Ensure your .prettierrc includes this plugin; do not expect it to format non-Vue code fences.
affects: >=0.0.1
breakingRequires Prettier ^3.5.3; older Prettier versions are incompatible.
fix
Update Prettier to ^3.5.3 or later.
affects: <0.0.1
deprecatedPlugin v0.0.10 is early stage; API may change in future versions.
fix
Pin exact version if stability is critical, or monitor releases.
affects: >=0.0.1 <1.0.0
gotchaDoes not support Vue single file components (.vue) outside of Markdown; use a separate Prettier Vue plugin for .vue files.
fix
Add @prettier/plugin-vue to your Prettier config for standalone .vue files.
affects: >=0.0.1
deprecatedPlugin works only within VitePress/VuePress Markdown; not intended for general Vue-in-Markdown use in other frameworks.
fix
Use only in projects that use VitePress or VuePress.
affects: >=0.0.1
gotchaTypeScript types are shipped but may not cover all plugin options; rely on Prettier's type system.
fix
Cast plugin config as needed.
affects: >=0.0.1
gotchaMust be listed in plugins array; placing it in overrides may not work as expected.
fix
List plugin at top-level plugins in .prettierrc.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Couldn't resolve plugin "prettier-plugin-vitepress"
Plugin not installed or not in node_modules.
fix
Run `npm add -D prettier-plugin-vitepress` to install.
Cannot find module 'prettier-plugin-vitepress'
Prettier cannot resolve the plugin in config.
fix
Use require.resolve: plugins: [require.resolve('prettier-plugin-vitepress')]
Error: Unknown parser 'vue'
Prettier version too old (<3.5.3) or plugin not loaded.
fix
Update Prettier to ^3.5.3 and ensure plugin is in plugins array.
Prettier encountered an unexpected token (in Markdown file)
Malformed Vue SFC inside Markdown; plugin expects valid Vue syntax.
fix
Check Vue template/script/style syntax and fix any errors.
TypeError: Cannot read properties of undefined (reading 'type')
Plugin error on unsupported pattern, possibly nested fences.
fix
Simplify the Markdown structure; avoid nested Vue fences.
Upgrade
Version history
0.0.10latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: requires Prettier ^3.5.3 to function as a plugin.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
prettier-plugin-vitepress — npm install prettier-plugin-vitepress · libregistry