Socket
Socket
Sign inDemoInstall

remark-parse

Package Overview
Dependencies
16
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remark-parse

remark plugin to parse Markdown


Version published
Weekly downloads
8.7M
decreased by-1.58%
Maintainers
2
Install size
624 kB
Created
Weekly downloads
 

Package description

What is remark-parse?

The remark-parse package is a plugin for the Remark processor that parses Markdown content into a syntax tree. It is part of the unified ecosystem, which provides a way to parse, transform, and stringify content using abstract syntax trees (ASTs).

What are remark-parse's main functionalities?

Parsing Markdown

This feature allows you to parse Markdown content and transform it into an abstract syntax tree (AST). The code sample demonstrates how to use remark-parse with the remark library to parse a simple Markdown string.

const remark = require('remark');
const parse = require('remark-parse');

remark().use(parse).process('# Hello world!', function(err, file) {
  if (err) throw err;
  console.log(file);
});

Extensible Markdown Parsing

remark-parse can be extended with plugins to handle custom Markdown syntax. In this example, the 'remark-math' plugin is used to parse mathematical expressions within the Markdown content.

const remark = require('remark');
const parse = require('remark-parse');
const math = require('remark-math');

remark().use(parse).use(math).process('Euler's identity: $e^{i\pi} + 1 = 0$', function(err, file) {
  if (err) throw err;
  console.log(file);
});

Other packages similar to remark-parse

Readme

Source

remark-parse

Build Coverage Downloads Size Sponsors Backers Chat

Parser for unified. Parses Markdown to mdast syntax trees. Built on micromark and mdast-util-from-markdown. Used in the remark processor but can be used on its own as well. Can be extended to change how Markdown is parsed.

Install

npm:

npm install remark-parse

Use

var unified = require('unified')
var createStream = require('unified-stream')
var markdown = require('remark-parse')
var remark2rehype = require('remark-rehype')
var html = require('rehype-stringify')

var processor = unified().use(markdown).use(remark2rehype).use(html)

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

See unified for more examples »

API

See unified for API docs »

processor().use(parse)

Configure the processor to read Markdown as input and process mdast syntax trees.

Extending the parser

See micromark and mdast-util-from-markdown. Then create a wrapper plugin such as remark-gfm.

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

Keywords

FAQs

Last updated on 14 Oct 2020

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