remark plugin to serialize Markdown as HTML.
⚠️ This package essentially packs
rehype-stringify, and although it does support some customisation, it isn’t very pluggable. It’s probably smarter to use
remark-rehypedirectly and benefit from the rehype ecosystem.
This plugin is ready for the new parser in remark
The current and previous version of the plugin works with the current and
previous version of remark.
npm install remark-html
Say we have the following file,
# Hello & World> A block quote.* Some _emphasis_, **importance**, and `code`.
And our script,
example.js, looks as follows:
var fs =var unified =var markdown =var html =
node example yields:
Hello & WorldA block quote.Some emphasis, importance, and code.
Serialize Markdown as HTML.
All options except for
handlers are passed to
How to sanitize the output (
false— HTML is not sanitized, dangerous HTML persists
true— HTML is sanitized according to GitHub’s sanitation rules, dangerous HTML is dropped
Object— the object is treated as a
schemafor how to sanitize with
hast-util-sanitize, dangerous HTML is dropped
For example, to add strict sanitation but allowing
classNames, use something
// ...var merge =var github =var schema =
remark-html works great with:
remark-autolink-headings— Automatically add links to headings in Markdown
remark-github— Generate references to GitHub issues, PRs, users, and more
remark-highlight.js— Highlight code blocks
remark-html-emoji-image— Transform emoji unicodes into html images
remark-html-katex— Transform math to HTML with KaTeX
remark-math— Math support for Markdown (inline and block)
remark-midas— Highlight CSS code with midas
remark-toc— Generate a Tables of Contents
- …and more
All mdast nodes can be compiled to HTML.
Unknown mdast nodes are compiled to
div nodes if they have
text nodes if they have
In addition, remark-html can be told how to compile nodes through
data properties (more information):
hName— Tag name to compile as
hChildren— HTML content to add (instead of
hProperties— Map of properties to add
For example, the following node:
type: 'emphasis'data:hName: 'i'hProperties: className: 'foo'hChildren: type: 'text' value: 'bar'children: type: 'text' value: 'baz'
remark-html is unsafe by default and opens you up to a
cross-site scripting (XSS) attack.
sanitize: true to prevent attacks.
sanitize to anything else may be unsafe.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.