gitmyhub

remark

JavaScript ★ 8.9k updated 3mo ago

markdown processor powered by plugins part of the @unifiedjs collective

Remark is a JavaScript Markdown processor that parses text into a syntax tree and lets a plugin pipeline transform, lint, reformat, or convert it to HTML, claimed to be the world's most popular Markdown parser.

JavaScriptNode.jssetup: easycomplexity 2/5

Remark is a JavaScript tool for processing Markdown text using a plugin system. Instead of converting Markdown to HTML directly and stopping there, remark first parses the Markdown into a tree structure (called an AST, or abstract syntax tree) where each heading, paragraph, link, and code block becomes a node you can inspect or modify with code. Plugins then walk that tree and do whatever they need: convert it to HTML, check for style inconsistencies, generate a table of contents, or restructure headings.

The project claims to be the world's most popular Markdown parser and it follows the CommonMark specification precisely. Extensions for GitHub-Flavored Markdown (which adds tables, strikethrough, footnotes, and task lists) and for MDX (Markdown with embedded JSX) are available as plugins. Over 150 plugins exist in the ecosystem, covering everything from linting and formatting to generating sitemaps and embedding code examples.

Remark is part of the larger unified ecosystem, which applies the same plugin pipeline approach to other content types like HTML (handled by rehype) and prose (handled by retext). Because all these tools use the same underlying pipeline pattern, you can chain them together: parse Markdown, transform it, then hand the tree off to rehype to produce HTML, all in a few lines.

This repository is a monorepo containing the core packages: remark-parse (reads Markdown into a tree), remark-stringify (writes a tree back out as Markdown), remark itself (combines both), and remark-cli (a command-line tool for linting and formatting Markdown files in a project). You can use it in Node.js, in the browser, on Deno, and in command-line scripts.

Where it fits