{"id":20389,"library":"prettier-plugin-mdc","title":"Prettier Plugin for MDC Syntax","description":"A Prettier plugin for formatting MDC (Markdown Components) syntax, as used in Nuxt Content. Current stable version is 0.2.1, released with bug fixes for extra newlines after frontmatter and fallback to mdast embed logic. Requires Prettier >=3.6.0. Ships TypeScript types. Differentiators: supports YAML front matter in components, nested components, GFM, and math syntax. Plugin must be added to Prettier config with the 'mdc' parser explicitly set via overrides. Works with .mdc and .md files.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/so1ve/prettier-plugin-mdc","tags":["javascript","prettier","prettier-plugin","mdc","markdown","remark","unified","typescript"],"install":[{"cmd":"npm install prettier-plugin-mdc","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-mdc","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-mdc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires Prettier version >=3.6.0 (as of v0.2.0)","package":"prettier","optional":false}],"imports":[{"note":"Not imported in code; added to Prettier config's plugins array. No JS import required.","wrong":"plugins: ['prettier-plugin-mdc'] // no default or named import needed; configured in prettier config","symbol":"plugin","correct":"plugins: ['prettier-plugin-mdc']"},{"note":"Must set parser to 'mdc' in Prettier overrides for .md or .mdc files. Using 'markdown' parser will not apply MDC-specific formatting.","wrong":"parser: 'markdown'","symbol":"parser","correct":"parser: 'mdc'"},{"note":"Package ships types but they are internal; use Prettier's own types for configuration. No direct type import from this package.","wrong":"import type { Options } from 'prettier-plugin-mdc'","symbol":"types (TypeScript)","correct":"import type { Options, Plugin } from 'prettier'"}],"quickstart":{"code":"// .prettierrc or prettier.config.js\n{\n  \"plugins\": [\"prettier-plugin-mdc\"],\n  \"overrides\": [\n    {\n      \"files\": [\"*.md\", \"*.mdc\"],\n      \"options\": {\n        \"parser\": \"mdc\"\n      }\n    }\n  ]\n}\n\n// CLI: prettier --write \"**/*.mdc\" \"**/*.md\"\n// Example MDC file (before formatting):\n// ::component{prop=value}\n// content\n// ::\n// After formatting: proper indentation and spacing","lang":"typescript","description":"Shows how to configure Prettier with the MDC plugin, including required overrides for parser, and example CLI usage."},"warnings":[{"fix":"Upgrade prettier to >=3.6.0","message":"Prettier >=3.6.0 required (v0.2.0+ breaks with older prettier)","severity":"breaking","affected_versions":"<3.6.0"},{"fix":"Add override: { files: ['*.md', '*.mdc'], options: { parser: 'mdc' } }","message":"Parser must be set to 'mdc' in overrides; using default 'markdown' parser will not format MDC syntax correctly","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Include desired file extensions in the files array of the override","message":"Plugin only formats .mdc and .md files; other file extensions require explicit parser override","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade to v0.2.0+ for prettier 3.8 compatibility","message":"v0.1.x required prettier 3.6.0+; v0.2.0 made it work with prettier 3.8","severity":"deprecated","affected_versions":"0.1.0 - 0.1.4"},{"fix":"Upgrade to v0.2.1+","message":"YAML front matter in components may lose extra newlines if not properly handled; v0.2.1 fixed extra newlines after frontmatter","severity":"gotcha","affected_versions":"<0.2.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install -D prettier-plugin-mdc","cause":"Package not installed or not installed as dev dependency","error":"Cannot find module 'prettier-plugin-mdc'"},{"fix":"Add overrides with parser: 'mdc' in Prettier config","cause":"Plugin registered but no parser override for .mdc or .md files","error":"Error: No parser and no filepath given, couldn't infer a parser."},{"fix":"Use array: \"overrides\": [{ \"files\": [\"*.md\"], \"options\": { \"parser\": \"mdc\" } }]","cause":"Incorrect prettier config format (e.g., overrides as object instead of array)","error":"Error: Invalid configuration file. Expected overrides to be an array."},{"fix":"Set parser in config file, not CLI. Run prettier --write without --parser","cause":"Using CLI option --parser instead of config override","error":"error: unknown option `--parser'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}