rehype-raw

A rehype plugin that reparses embedded raw HTML in a hast tree so it becomes real syntax nodes.

Library
npm
v7.0.0
211 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
38 /100 Needs Attention
Development Activity 0
Maintenance 20
Community 52
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 88
Code Quality 90
Innovation 85
Learning Curve 60

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 tagfilter mode to neutralize dangerous tags like script, iframe, and style
  • A passThrough option to keep specified custom node types untouched during reparsing
  • Full TypeScript types (ESM-only, ships an Options type)

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-rehype output generated with allowDangerousHtml: 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

Go
68%
MIT

Probo

Automation · Security

1,476

Open-source GRC platform for engineering and security teams.

View details
87
Repo Health
90
Technical
69
Dependency
Built with
Go 68%
TypeScript 30%
Updated 6 days ago
TypeScript
67%
MIT

Scalar

Developer Tools

16,313

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 67%
Vue 29%
Updated 5 days ago
TypeScript
50%
Other

SigNoz

Analytics · Monitoring

32,429

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
64
Dependency
Built with
TypeScript 50%
Go 38%
Updated 6 days ago
Python
88%
Apache 2.0

sirchmunk

AI Development · Data Engineering

1,379

Drop your files and search them instantly — no vector DB, no indexing pipeline, just raw data queried by a self-evolving intelligence layer.

View details
85
Repo Health
70
Technical
72
Dependency
Built with
Python 88%
TypeScript 11%
Updated 6 days ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
Rust
79%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,292

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
84
Repo Health
84
Technical
63
Dependency
Built with
Rust 79%
TypeScript 18%
Updated 2 weeks ago
TypeScript
92%
Other

Suna

AI Agents

20,306

Turn your company into a git repo — one config, one command center, a workforce of AI agents that runs the real work around the clock.

View details
90
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 92%
Updated 5 days ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 5 days ago
Python
71%
Apache 2.0

SurfSense

AI Assistants · Search

16,586

The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.

View details
88
Repo Health
71
Technical
66
Dependency
Built with
Python 71%
TypeScript 27%
Updated 5 days ago

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