rst-renderer

reStructuredText rendering for JavaScript / TypeScript

Parse RST to a unified AST, then render to HTML, React components, or Markdown. Built-in Jinja2-compatible template engine, Vite plugin, and CLI tool. Full CJK support for Chinese documentation and bioinformatics report generation.

Packages

Features

🎨

HTML 渲染

11 个指令插件,Shiki 代码高亮,KaTeX 数学公式,CSS class 可定制

⚛️

React 渲染

RST → React 组件树,支持自定义组件覆盖每个节点类型

📝

Markdown

RST → GFM 格式,heading offset 可配,支持表格/代码块/图片

📋

Jinja2 模板

嵌套 for/if/else,12 个 filter,loop 变量,兼容 annopi RST 模板

🀄

CJK 中文

中文标题/段落/内联标记全链路支持,annopi 生信报告模板

🔷

TypeScript

完整的类型定义,ESM + DTS 双输出,可插拔解析器架构

Quick Start
pnpm add @seqyuan/rst-renderer

import { renderRst } from '@seqyuan/rst-renderer'

const html = renderRst(`Hello
=====

This is **bold** and *italic* text.

- item 1
- item 2

.. note:: This will be rendered as an admonition box.
`)

// → <h2 id="hello">Hello</h2>
//   <p>This is <strong>bold</strong> and <em>italic</em> text.</p>
//   <ul><li>item 1</li><li>item 2</li></ul>
//   <div class="admonition admonition-note">...</div>