rehype-raw
A rehype plugin that reparses embedded raw HTML in a hast tree so it becomes real syntax nodes.
Repository Health
Technical Analysis
rehype-raw is a unified/rehype plugin that takes a hast (HTML AST) tree containing strings of raw HTML and reparses it through the parse5 HTML parser, recreating the tree exactly as a browser would while preserving the original data and positional information. It is the standard bridge for pipelines that come from markdown with embedded HTML: after remark-rehype passes HTML through as opaque raw nodes, rehype-raw turns those strings into actual element nodes so downstream plugins, and output formats like React or MDX, can operate on a proper tree instead of unparseable HTML strings.
What You Get
- A single default-export rehype plugin you drop into a
unified().use(...)chain - Accurate reparsing of embedded raw HTML into hast element nodes via the parse5 browser-grade parser
- Preserved positional information (line/column data) across the reparse
- An optional GFM
tagfiltermode to neutralize dangerous tags likescript,iframe, andstyle - A
passThroughoption to keep specified custom node types untouched during reparsing - Full TypeScript types (ESM-only, ships an
Optionstype)
Common Use Cases
- Rendering markdown that contains inline HTML to React or MDX components
- Running rehype transform plugins over content that mixed in raw HTML blocks
- Producing a clean HTML AST from
remark-rehypeoutput generated withallowDangerousHtml: true - Applying GFM tagfilter rules to block irregular or unsafe tags in user-authored HTML
Under The Hood
Architecture
The package is intentionally thin. The public entry index.js re-exports the default from lib/index.js, which defines a single rehypeRaw(options) factory. That factory returns a unified transformer (tree, file) that delegates all real work to raw() from hast-util-raw, spreading the caller’s options and injecting the current file so positional/message context is preserved. hast-util-raw in turn runs the tree through parse5, so the tree is reconstructed exactly as a browser HTML parser would build it. The plugin itself owns no parsing logic — it is a well-scoped adapter that wires rehype’s plugin contract onto the underlying hast utility.
Tech Stack
Written in modern ESM JavaScript targeting Node.js 16+, with types authored as JSDoc and emitted to .d.ts via the TypeScript compiler (tsc --build). Runtime dependencies are minimal and current: hast-util-raw ^9, @types/hast ^3, and vfile ^6. Tooling includes xo + prettier for lint/format, remark-cli with remark-preset-wooorm for docs, c8 for coverage, and type-coverage enforcing 100% typed code. There is no bundler — the package ships source ESM directly.
Code Quality
Code quality is high for a micro-package. type-coverage is pinned at 100% with strict TypeScript checking of JS, and the tsconfig enables strict and exactOptionalPropertyTypes. test.js uses the built-in node:test runner with node:assert/strict and covers the public API surface, the core markdown-with-embedded-HTML reparse case, and the tagfilter behavior; the CI test script requires 100% coverage via c8 --100. Naming and structure are clear, and the single transformer is small enough to reason about completely.
API Design
The API is minimal and idiomatic to unified: a default export you .use() with an optional options object (passThrough, tagfilter). There are no other identifiers to learn, options mirror the underlying hast-util-raw configuration, and the README’s runnable end-to-end example gets a new user productive quickly. The main friction is conceptual rather than ergonomic — using it well requires understanding the hast AST and where reparsing fits in a remark/rehype pipeline.
Used by 41 apps in this directory
Lightdash
Analytics · Data Engineering
The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.
Lokus
Knowledge Management · Note Taking
Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.
Magic
AI Agents · Automation · Low Code Platforms
Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.
Markdrop
Note Taking
Visual drag-and-drop markdown editor with GitHub-specific blocks, cloud sync, and offline PWA support
memos
Note Taking
Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.
Multica
AI Assistants · AI Development
Turn coding agents into real teammates — assign issues, track progress, and compound reusable skills across a vendor-neutral, self-hosted platform.
NocoBase
Low Code Platforms · No Code Platforms
Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.
Ollama
AI Development · Developer Tools
Run Llama, Gemma, DeepSeek, and other open LLMs on your own machine with one command and an OpenAI-compatible API.
Orca
AI Agents · AI Code Assistants
An open-source Agent Development Environment that orchestrates fleets of parallel AI coding agents — Claude Code, Codex, Gemini and more — each running in its own isolated git worktree.