prettier-plugin-markdown-html
v1.6.1
Published
Format raw HTML in Markdown with Prettier
Downloads
5,583
Maintainers
Readme
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-htmlpnpm add --save-dev prettier-plugin-markdown-htmlUsage
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 {
/**
* Keep the closing bracket on the last attribute line in block-level raw
* HTML fragments in Markdown. Unlike `bracketSameLine`, this option does
* not affect code blocks. Falls back to `bracketSameLine` when unset.
* @default undefined
*/
htmlFragmentBracketSameLine?: boolean | undefined;
/**
* Control formatting of `<script>` and `<style>` contents in raw HTML
* fragments in Markdown. Unlike `embeddedLanguageFormatting`, this option
* does not affect code blocks. Falls back to `embeddedLanguageFormatting`
* when unset.
* @default undefined
*/
htmlFragmentEmbeddedLanguageFormatting?: 'auto' | 'off' | undefined;
/**
* 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
