remark-rehype

A unified/remark plugin that converts a markdown (mdast) syntax tree into an HTML (hast) syntax tree, bridging the remark and rehype ecosystems.

Library
npm
v11.1.2
361stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity0
Maintenance20
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture80
Code Quality85
Innovation55
Learning Curve90

remark-rehype is the plugin that lets a unified/remark pipeline hand off from the markdown world to the HTML world. Markdown processing (mdast, remark) and HTML processing (hast, rehype) are deliberately separate ecosystems in unifiedjs, because turning markdown into HTML is only one of many things people do with a markdown syntax tree (linting and formatting being two others). remark-rehype is the one plugin whose entire job is transforming an mdast tree into a hast tree via mdast-util-to-hast, after which every plugin used further down the unified().use(...) chain must be a rehype plugin rather than a remark plugin.

Beyond the core mdast-to-hast conversion, the package’s options exist almost entirely to handle the places where markdown and HTML don’t map 1-to-1: allowDangerousHtml controls whether raw HTML embedded in markdown is preserved as hast raw nodes (for later handling by rehype-raw or rehype-stringify), and a cluster of footnote* options (footnoteLabel, footnoteBackLabel, footnoteLabelProperties, clobberPrefix, etc.) control how GitHub-style footnotes are rendered accessibly and safely, since footnote IDs are derived from user content and are a known DOM-clobbering vector. Custom handlers and a passThrough list let callers override or preserve specific node types during the conversion.

It’s maintained by the remarkjs/unifiedjs core team (primarily Titus Wormer) as one of the most widely depended-upon links in the modern static site and markdown tooling chain — MDX, Astro, Next.js MDX, Docusaurus and countless documentation and blog pipelines route through it whenever they need to render markdown as HTML.

What You Get

  • A unified().use(remarkRehype, options) plugin that transforms an mdast tree into a hast tree, switching the rest of the pipeline into rehype-plugin territory
  • Optional bridge mode (pass a destination processor) that runs a separate rehype pipeline against the hast tree and discards its result, versus the default mutate mode that returns the hast tree directly
  • Configurable, accessible footnote rendering (footnoteLabel, footnoteBackLabel, footnoteLabelProperties, clobberPrefix) that guards against DOM-clobbering via generated id attributes
  • An allowDangerousHtml option to optionally preserve raw HTML found in markdown as hast raw nodes for downstream handling by rehype-raw or rehype-stringify
  • Escape hatches for tree conversion: handlers to override how specific mdast node types are converted, passThrough to keep custom node types untouched, and unknownHandler for anything not otherwise recognized
  • Full TypeScript types (100% type-coverage enforced in CI) for Options and all exported handler types

Common Use Cases

  • Rendering markdown files to HTML in a static site generator or documentation build, piping remark-parse output through remark-rehype into rehype-stringify
  • Building custom MDX-adjacent content pipelines that need rehype-side plugins (syntax highlighting via rehype-starry-night, sanitization via rehype-sanitize, HTML minification/formatting) after markdown parsing
  • Rendering GitHub-flavored markdown with footnotes into accessible HTML, using the footnote-related options to produce correct ARIA-labeled backreferences
  • Supporting raw HTML embedded in trusted markdown content by enabling allowDangerousHtml in combination with rehype-raw
  • Feeding a bridge-mode unified() destination processor to run a full independent rehype pipeline against generated HTML without altering the outer markdown-based pipeline’s own output

Under The Hood

Architecture remark-rehype is intentionally minimal: index.js re-exports defaultFootnoteBackContent, defaultFootnoteBackLabel, and defaultHandlers from mdast-util-to-hast alongside a default export from lib/index.js, which is the entire implementation. That single function, remarkRehype(destination, options), is a unified plugin factory with two runtime shapes chosen by inspecting whether the first argument looks like a unified Processor (has a run method): bridge mode returns an async transformer that converts the mdast tree to hast via toHast() and runs it through the given destination processor, discarding the result; mutate mode returns a synchronous transformer that converts and returns the hast tree directly so later .use() calls in the same pipeline operate on it. All the real tree-conversion logic — node type mapping, footnote handling, DOM-clobbering-safe ID generation, raw-HTML handling — lives in the separate mdast-util-to-hast dependency; remark-rehype itself is a thin, well-documented adapter around it, meaning the entire pipeline’s mdast-to-hast behavior would change if that dependency’s behavior changed.

Tech Stack The package is pure ESM-only JavaScript ("type": "module") with zero runtime framework dependencies beyond the unified ecosystem: mdast-util-to-hast for the actual conversion, unified and vfile for the pipeline/file abstractions it operates within, and @types/hast/@types/mdast purely as type dependencies. There’s no bundler and no build step for the runtime code — tsc is used only in emitDeclarationOnly mode to generate .d.ts files from the plain JS source via extensive JSDoc type annotations, and the project targets ES2022 with Node.js 16+.

Used by 13 apps in this directory

TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,893

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript100%
Updated 3 days ago
Java
73%
Other

ByteChef

Automation · AI Agents

1,000

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
70
Dependency
Built with
Java73%
TypeScript26%
Updated yesterday
TypeScript
89%
Other

FastGPT

AI Agents · AI Development

29,591

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
69
Dependency
Built with
TypeScript89%
Updated yesterday
Python
64%
Other

Keep

Devops · Automation · Monitoring

12,290

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
91
Repo Health
79
Technical
66
Dependency
Built with
Python64%
TypeScript36%
Updated yesterday
TypeScript
97%
MIT

likec4

Developer Tools · Devops

5,634

Define your software architecture as code and get always up-to-date, interactive C4 diagrams generated automatically from a DSL.

View details
89
Repo Health
83
Technical
77
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
95%
Other

LLM Gateway

AI Development · Devops

1,611

One API endpoint for 25+ LLM providers — route, track costs, enforce compliance, and switch models without changing your code.

View details
85
Repo Health
80
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,861

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
90
Repo Health
77
Technical
62
Dependency
Built with
TypeScript64%
Vue31%
Updated 2 days ago
Python
64%
Other

Onyx

AI Assistants · AI Agents · Knowledge Management

31,948

Self-hostable AI platform with agentic RAG, 50+ connectors, deep research, code execution, and support for every major LLM provider.

View details
92
Repo Health
83
Technical
71
Dependency
Built with
Python64%
TypeScript27%
Updated yesterday
TypeScript
81%
AGPL 3.0

OpenStatus

Monitoring · Devops

9,072

Open-source status pages and uptime monitoring with global synthetic checks, monitoring-as-code, and AI agent integration via MCP.

View details
77
Repo Health
82
Technical
69
Dependency
Built with
TypeScript81%
MDX15%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search