rehype-remark

plugin to transform from HTML (rehype) to Markdown (remark)

Showing:

Popularity

Downloads/wk

25.8K

GitHub Stars

28

Maintenance

Last Commit

2mos ago

Contributors

3

Package

Dependencies

4

License

MIT

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

rehype-remark

Build Coverage Downloads Size Sponsors Backers Chat

rehype plugin to bridge or mutate to remark.

Tiny wrapper around hast-util-to-mdast.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install rehype-remark

Use

Say our example.js looks as follows:

import {unified} from 'unified'
import {stream} from 'unified-stream'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'

const processor = unified()
  .use(rehypeParse)
  .use(rehypeRemark)
  .use(remarkStringify)

process.stdin.pipe(stream(processor)).pipe(process.stdout)

Now, when running the following in a terminal (2>/dev/null is just to silence Curl’s debugging output):

curl https://example.com 2>/dev/null | node example.js

stdout(4) yields:

# Example Domain

This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.

[More information...](https://www.iana.org/domains/example)

API

This package exports no identifiers. The default export is rehypeRemark.

unified().use(rehypeRemark[, destination][, options])

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

destination

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

options

Options are passed to hast-util-to-mdast. Note that options.document defaults to true in rehype-remark, as this plugin is mostly used with blocks.

Security

Use of rehype-remark can open you up to a cross-site scripting (XSS) attack if the tree is unsafe. Use rehype-sanitize to make the tree safe.

Contribute

See contributing.md in rehypejs/.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.

License

MIT © Titus Wormer

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100