Registry / web-framework / prettier-plugin-markdown-html

prettier-plugin-markdown-html

JSON →
library1.4.0jsnpmunverified

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.

npm install prettier-plugin-markdown-html
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-MA
P
prettier-plugin-markdown-html
web-frameworkjavascriptv1.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default (plugin auto-discovery)
Add 'prettier-plugin-markdown-html' to plugins array in Prettier config.
No JavaScript import needed; plugin is auto-discovered by Prettier when listed in config.

Minimal Prettier config enabling the plugin with custom fragment options, plus example input/output showing HTML formatting in Markdown.

// .prettierrc { "plugins": ["prettier-plugin-markdown-html"], "htmlFragmentPrintWidth": 80, "htmlFragmentSingleAttributePerLine": false, "htmlFragmentWhitespaceSensitivity": "css" } // Example input.md: // # Title // <div class="container" ><p>Hello</p></div> // Run: npx prettier --write input.md // Output: // # Title // <div class="container"> // <p>Hello</p> // </div>
Debug
Known issues
deprecatedVersions before 1.0.0 were experimental and may have unstable behavior.
fix
Upgrade to ^1.0.0 or later.
affects: <1.0.0
breakingNode.js versions below 20 are not supported. The plugin requires node >=20.
fix
Update Node.js to version 20 or higher.
affects: >=1.0.0
gotchaPlugin options like htmlFragmentPrintWidth only affect raw HTML fragments, not code blocks or other Markdown content. Setting them may not have the expected global effect.
fix
Use these options only for fragment-specific tuning; consider using global printWidth for overall formatting.
affects: >=1.0.0
deprecatedVersions 1.0.0 and 1.1.0 had a bug where htmlFragmentWhitespaceSensitivity was not always respected. Fixed in 1.2.0.
fix
Upgrade to >=1.2.0 to ensure the option works correctly.
affects: >=1.0.0 <1.2.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-markdown-html'
Plugin not installed or not in node_modules.
fix
Run `npm install --save-dev prettier-plugin-markdown-html` and ensure your Prettier config has it listed under 'plugins'.
Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
Prettier is loaded via require() but plugin uses ESM.
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.
TypeError: Cannot read properties of undefined (reading 'options')
Plugin loaded incorrectly (e.g., double import or old Prettier version).
fix
Upgrade Prettier to >=3.0.0 and ensure the plugin is listed once in the plugins array.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; must be >=3.0.0
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-markdown-html — npm install prettier-plugin-markdown-html · libregistry