Socket
Socket
Sign inDemoInstall

remark-stringify

Package Overview
Dependencies
26
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remark-stringify

remark plugin to compile markdown


Version published
Maintainers
2
Install size
613 kB
Created

Readme

Source

remark-stringify

Build Coverage Downloads Size Chat Sponsors Backers

Compiler for unified. Serializes mdast syntax trees to markdown. Used in the remark processor but can be used on its own as well. Can be extended to change how markdown is serialized.

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-stringify

Use

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

unified()
  .use(rehypeParse)
  .use(rehypeRemark)
  .use(remarkStringify, {
    bullet: '*',
    fence: '~',
    fences: true,
    incrementListMarker: false
  })
  .process('<h1>Hello, world!</h1>')
  .then((file) => {
    console.log(String(file))
  })

Yields:

# Hello, world!

See unified for more examples »

API

See unified for API docs »

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

unified().use(remarkStringify[, options])

Configure the processor to serialize mdast syntax trees to markdown.

options

Options can be passed directly or passed later through processor.data().

All the formatting options of mdast-util-to-markdown are supported and will be passed through.

Extending the compiler

See mdast-util-to-markdown. Then create a wrapper plugin such as remark-gfm.

Security

remark-stringify will do its best to serialize markdown to match the syntax tree, but there are several cases where that is impossible. It’ll do its best, but complete roundtripping is impossible given that any value could be injected into the tree.

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-stringify and parsing it again later can potentially be unsafe. When parsing markdown afterwards, 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

Keywords

FAQs

Last updated on 03 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc