Format raw HTML in Markdown with Prettier
- Types
- ESM
- License
- MIT
- Deps
- 0
- Install Size
- 32.4 kB
- Vulns
- 0
- Published
$
npm install prettier-plugin-markdown-html$
pnpm add prettier-plugin-markdown-html$
yarn add prettier-plugin-markdown-html$
bun add prettier-plugin-markdown-html$
deno add npm:prettier-plugin-markdown-html$
vlt install prettier-plugin-markdown-html$
vp add prettier-plugin-markdown-html$
nub add prettier-plugin-markdown-html# Usually installed as a dev dependency
$
npm install -D prettier-plugin-markdown-html$
pnpm add -D prettier-plugin-markdown-html$
yarn add -D prettier-plugin-markdown-html$
bun add -d prettier-plugin-markdown-html$
deno add -D npm:prettier-plugin-markdown-html$
vlt install -D prettier-plugin-markdown-html$
vp add -D prettier-plugin-markdown-html$
nub add -D prettier-plugin-markdown-htmlprettier-plugin-markdown‑html
Format raw HTML in Markdown with Prettier.
Overview
This plugin adds an extra level of consistency to Markdown files by formatting raw HTML fragments.
- Works with
README.mdand any other GitHub-Flavored Markdown document. - Respects Prettier’s built-in HTML options.
- Comes without any additional dependencies.
Install
npm install --save-dev prettier-plugin-markdown-html
pnpm add --save-dev prettier-plugin-markdown-html
Usage
Reference prettier-plugin-markdown-html in your Prettier config:
{
"plugins": [
"prettier-plugin-markdown-html"
]
}
Options
In addition to Prettier’s built-in options that affect HTML formatting, prettier-plugin-markdown-html offers additional configuration options.
interface PluginOptions {
/**
* Override the preferred line length for raw HTML fragments in Markdown.
* Unlike `printWidth`, this option does not affect code blocks or other
* Markdown content. Falls back to `printWidth` when unset.
* @default undefined
*/
htmlFragmentPrintWidth?: number | undefined;
/**
* Enforce one HTML attribute per line for raw HTML fragments in Markdown.
* Unlike `singleAttributePerLine`, this option does not affect code blocks.
* Falls back to `singleAttributePerLine` when unset.
* @default undefined
*/
htmlFragmentSingleAttributePerLine?: boolean | undefined;
/**
* Control whitespace handling for raw HTML fragments in Markdown. Unlike
* `htmlWhitespaceSensitivity`, this option does not affect code blocks.
* Falls back to `htmlWhitespaceSensitivity` when unset.
* @default undefined
*/
htmlFragmentWhitespaceSensitivity?: 'css' | 'strict' | 'ignore' | undefined;
}
Related
License
MIT © Dom Porada