remark

Markdown processor powered by plugins part of the unified collective

Usage no npm install needed!

<script type="module">
  import remark from 'https://cdn.skypack.dev/remark';
</script>

README

remark

Build Coverage Downloads Size Sponsors Backers Chat

unified processor to parse and serialize markdown. Built on micromark. Powered by plugins. Part of the unified collective.

Don’t need the parser? Or compiler? That’s OK: use unified directly.

Install

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

npm:

npm install remark

Use

See unified for more examples »

Common example

This example lints markdown and turns it into HTML.

import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
import remarkHtml from 'remark-html'

remark()
  .use(remarkPresetLintRecommended)
  .use(remarkHtml)
  .process('## Hello world!')
  .then((file) => {
    console.error(reporter(file))
    console.log(String(file))
  })

Yields:

  1:1  warning  Missing newline character at end of file  final-newline  remark-lint

⚠ 1 warning
<h2>Hello world!</h2>
Settings through data

This example prettifies markdown and configures remark-stringify through data.

import {remark} from 'remark'

remark()
  .data('settings', {emphasis: '*', strong: '*'})
  .process('_Emphasis_ and __importance__')
  .then((file) => {
    console.log(String(file))
  })

Yields:

*Emphasis* and **importance**
Settings through a preset

This example prettifies markdown and configures remark-parse and remark-stringify through a preset.

import {remark} from 'remark'

remark()
  .use({settings: {emphasis: '*', strong: '*'}})
  .process('_Emphasis_ and __importance__')
  .then((file) => {
    console.log(String(file))
  })

Yields:

*Emphasis* and **importance**

API

See unified for API docs »

This package exports the following identifier: remark. There is no default export.

Security

As markdown is sometimes used for HTML, and improper use of HTML can open you up to a cross-site scripting (XSS) attack, use of remark can also be unsafe. When going to HTML, use remark in combination with the rehype ecosystem, and use rehype-sanitize to make the tree safe.

Use of remark plugins could also open you up to other attacks. Carefully assess each plugin and the risks involved in using them.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help. Ideas for new plugins and tools can be posted in remarkjs/ideas.

A curated list of awesome remark resources can be found in awesome remark.

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

Sponsor

Support this effort and give back by sponsoring on OpenCollective!

Gatsby 🥇

Vercel 🥇

Netlify

Holloway

ThemeIsle

Boost Hub

Expo


You?

License

MIT © Titus Wormer