Documentation Index
Fetch the complete documentation index at: https://mintlify.com/remarkjs/remark/llms.txt
Use this file to discover all available pages before exploring further.
remark-parse is a unified plugin that teaches a processor how to take a markdown string as input and produce an mdast syntax tree. It is the parse half of the remark ecosystem. Internally it delegates to mdast-util-from-markdown, which itself is powered by micromark — a small, safe, and CommonMark-compliant markdown parser. Other plugins can extend the parser by registering micromark and mdast extensions through the processor’s data store.
Installation
API
unified().use(remarkParse)
Adds support for parsing markdown into an mdast syntax tree. This sets processor.parser so that any subsequent call to .process() or .parse() on the processor will accept a markdown string as input.
Import: import remarkParse from 'remark-parse'Parameters: None — the plugin takes no configuration options.
Returns:
undefined. The plugin mutates the processor by assigning its parser.TypeScript type:
Plugin<[(Readonly<Options> | null | undefined)?], string, Root>
Options
The Options type is exported for TypeScript consumers. It is currently empty (all fields are inherited from mdast-util-from-markdown except the internal extensions and mdastExtensions fields, which are managed by the plugin itself). Passing an options object is accepted but has no effect today; the type exists to allow forward-compatible extensions.
Processor data keys
Other plugins that extend the markdown syntax register their contributions through the unified processor’sdata store rather than through remark-parse options directly. remark-parse reads two keys:
An array of micromark extensions to use when tokenising the input string. Plugins such as
remark-gfm push into this array via processor.data('micromarkExtensions', [...]).An array of mdast-util-from-markdown extensions that translate micromark tokens into mdast nodes. Plugins push into this array via
processor.data('fromMarkdownExtensions', [...]).Examples
Parsing markdown to HTML
This is the most common use ofremark-parse — converting markdown to HTML by routing the mdast tree through rehype:
Supporting GFM and frontmatter
CommonMark is the only syntax supported by default. Non-standard extensions are opt-in via plugins. The following example adds GitHub Flavored Markdown (GFM) and YAML frontmatter parsing:Turning markdown into a man page
Man pages use a legacy markup format called roff. Theremark-man plugin serializes an mdast tree into roff, which means remark-parse can be paired with it directly — no HTML step required:
When both the input and output of your pipeline are markdown, use the
remark package instead of combining unified + remark-parse + remark-stringify manually. remark is a shortcut that sets up all three for you.Syntax
Markdown is parsed according to CommonMark. Other plugins can add support for syntax extensions. If you are building a micromark extension, see micromark’s extension documentation for details on how the extension API works.Syntax tree
The syntax tree produced byremark-parse is mdast. Each node conforms to the mdast specification, meaning downstream plugins and transformers receive a well-defined, typed tree.
TypeScript
This package is fully typed with TypeScript. It exports the additional typeOptions. It also augments the unified Data interface to declare micromarkExtensions and fromMarkdownExtensions, giving type safety to plugins that push into those arrays.
Compatibility
remark-parse@11 is compatible with Node.js 16 and later. The package is ESM only.