{"id":20386,"library":"prettier-plugin-markdown-html","title":"prettier-plugin-markdown-html","description":"A Prettier plugin that formats raw HTML fragments inside Markdown files (e.g., README.md), including those split by Markdown syntax. Version 1.4.0, stable, actively maintained. Released under MIT, ships TypeScript types. Key differentiators: respects Prettier's built-in HTML options, has no additional dependencies, and offers fragment-specific options like htmlFragmentPrintWidth and htmlFragmentSingleAttributePerLine that override global Prettier settings without affecting code blocks.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/porada/prettier-plugin-markdown-html","tags":["javascript","formatting","gfm","github","github-flavored-markdown","html","markdown","markdown-html","md","typescript"],"install":[{"cmd":"npm install prettier-plugin-markdown-html","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-markdown-html","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-markdown-html","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; must be >=3.0.0","package":"prettier","optional":false}],"imports":[{"note":"No JavaScript import needed; plugin is auto-discovered by Prettier when listed in config.","wrong":"","symbol":"default (plugin auto-discovery)","correct":"Add 'prettier-plugin-markdown-html' to plugins array in Prettier config."}],"quickstart":{"code":"// .prettierrc\n{\n  \"plugins\": [\"prettier-plugin-markdown-html\"],\n  \"htmlFragmentPrintWidth\": 80,\n  \"htmlFragmentSingleAttributePerLine\": false,\n  \"htmlFragmentWhitespaceSensitivity\": \"css\"\n}\n\n// Example input.md:\n// # Title\n// <div   class=\"container\"   ><p>Hello</p></div>\n\n// Run: npx prettier --write input.md\n// Output:\n// # Title\n// <div class=\"container\">\n//   <p>Hello</p>\n// </div>","lang":"javascript","description":"Minimal Prettier config enabling the plugin with custom fragment options, plus example input/output showing HTML formatting in Markdown."},"warnings":[{"fix":"Upgrade to ^1.0.0 or later.","message":"Versions before 1.0.0 were experimental and may have unstable behavior.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Update Node.js to version 20 or higher.","message":"Node.js versions below 20 are not supported. The plugin requires node >=20.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use these options only for fragment-specific tuning; consider using global printWidth for overall formatting.","message":"Plugin options like htmlFragmentPrintWidth only affect raw HTML fragments, not code blocks or other Markdown content. Setting them may not have the expected global effect.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to >=1.2.0 to ensure the option works correctly.","message":"Versions 1.0.0 and 1.1.0 had a bug where htmlFragmentWhitespaceSensitivity was not always respected. Fixed in 1.2.0.","severity":"deprecated","affected_versions":">=1.0.0 <1.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev prettier-plugin-markdown-html` and ensure your Prettier config has it listed under 'plugins'.","cause":"Plugin not installed or not in node_modules.","error":"Cannot find module 'prettier-plugin-markdown-html'"},{"fix":"Ensure Prettier is run in ESM mode (e.g., use `node --experimental-vm-modules` or configure Prettier to use ESM loader) or switch to a CJS-compatible version.","cause":"Prettier is loaded via require() but plugin uses ESM.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported."},{"fix":"Upgrade Prettier to >=3.0.0 and ensure the plugin is listed once in the plugins array.","cause":"Plugin loaded incorrectly (e.g., double import or old Prettier version).","error":"TypeError: Cannot read properties of undefined (reading 'options')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}