Project: remarkjs/remark-rehype

Package: remark-rehype@8.1.0

  1. Dependencies: 1·Dependents: 195
  2. remark plugin to transform to rehype
  1. remark 198
  2. unified 168
  3. markdown 138
  4. plugin 133
  5. html 110
  6. mdast 88
  7. rehype 75
  8. remark-plugin 75
  9. hast 61
  10. rehype-plugin 53


Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to bridge or mutate to rehype.

Note: remark-rehype doesn’t deal with HTML inside the Markdown. You’ll need rehype-raw if you’re planning on doing that.


This plugin is ready for the new parser in remark (remarkjs/remark#536). The current and previous versions of the plugin work with the current and previous versions of remark.



npm install remark-rehype


Say we have the following file, example.md:

# Hello world

> Block quote.

Some _emphasis_, **importance**, and `code`.

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var unified = require('unified')
var markdown = require('remark-parse')
var remark2rehype = require('remark-rehype')
var doc = require('rehype-document')
var format = require('rehype-format')
var html = require('rehype-stringify')

  .process(vfile.readSync('example.md'), function (err, file) {
    console.error(report(err || file))

Now, running node example yields:

example.md: no issues found
<!doctype html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <h1>Hello world</h1>
      <p>Block quote.</p>
    <p>Some <em>emphasis</em>, <strong>importance</strong>, and <code>code</code>.</p>


origin.use(remark2rehype[, destination][, options])

remark (mdast) plugin to bridge or mutate to rehype (hast).


If a Unified processor is given, runs the destination processor with the new hast tree, then, after running discards that tree and continues on running the origin processor with the original tree (bridge mode). Otherwise, passes the tree to further plugins (mutate mode).


Passed to mdast-util-to-hast.


Use of remark-rehype can open you up to a cross-site scripting (XSS) attack. Embedded hast properties (hName, hProperties, hChildren), custom handlers, and the allowDangerousHtml option all provide openings. Use rehype-sanitize to make the tree safe.


See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer