用途:将 Mermaid 图表渲染为 SVG 或 ASCII/Unicode 文本,适合服务端、终端或无浏览器环境生成示意图。基于 beautiful-mermaid npm 包,零 DOM 依赖,纯 TypeScript。
主要能力:支持流程图(graph/flowchart)、状态图(stateDiagram-v2)、时序图(sequenceDiagram)、类图(classDiagram)、ER 图(erDiagram)的 SVG 与 ASCII 输出。内置 15 种主题(如 tokyo-night、dracula、github-dark、nord、catppuccin 等),支持双色 mono 模式,仅给 bg 与 fg 即可自动派生其余颜色。另提供 fromShikiTheme 转换 VS Code/Shiki 主题。
安装:npm install beautiful-mermaid 或 bun add beautiful-mermaid。
使用方式:可用附带脚本一次性渲染,如 node ~/.claude/skills/beautiful-mermaid/scripts/render.mjs diagram.mmd -o diagram.svg;加 --ascii 输出文本;加 --theme tokyo-night 指定主题;支持 --inline 字符串与 stdin 输入。编程 API:SVG 用异步 renderMermaid(source, options),ASCII 用同步 renderMermaidAscii(source, options)。渲染选项含 bg、fg、line、accent、muted、surface、border、font、padding、nodeSpacing、layerSpacing、transparent;ASCII 选项含 useAscii、paddingX、paddingY、boxBorderPadding。
适用场景:终端/ASCII 输出、编辑器主题风格图表、无 Puppeteer 的服务端渲染,以及流程图、时序图、类图、状态图、ER 图。
限制:不支持 C4、Gantt、timeline、user journey、mindmap、pie、git graph,这些需改用 doc-mermaid(mmdc)。完整 Mermaid 语法兼容性亦以 mmdc 方案为佳。收费、价格与具体平台支持等资料暂未提供。