AI Agent Skill to generate and render beautiful Mermaid diagrams as SVG or terminal ASCII — 15 themes, 6 diagram types, batch CLI, no browser.
JavaScript agent-skillsai-agentsascii-artclaude-codecodexcursordiagram-generatordocumentationflowchartmermaidmermaid-diagramskillssvg
feat: sync skill with beautiful-mermaid 1.1.3
sunmozong13e509d5936d
diff --git a/README.md b/README.mdindex ba5597f..d72aa20 100644--- a/README.md+++ b/README.md@@ -23,7 +23,7 @@ A Mermaid diagram rendering skill for AI, supporting both SVG and ASCII output f- 📊 **Multi-format Support**: SVG and ASCII rendering export- 🎨 **Rich Themes**: 15 built-in themes for different scenarios-- 📈 **Full Diagram Support**: Flowchart, Sequence, State, Class, ER and more+- 📈 **Six Diagram Types**: Flowchart, Sequence, State, Class, ER, and XY charts- ⚡ **High Performance**: Batch parallel rendering- 📚 **Ready to Use**: Complete templates and detailed documentation@@ -32,8 +32,8 @@ A Mermaid diagram rendering skill for AI, supporting both SVG and ASCII output f| :--- | :--- | :--- || zinc-light | zinc-dark | nord || tokyo-night-light | tokyo-night | nord-light |-| cappuccin-latte | tokyo-night-storm | dracula |-| github-light | cappuccin-mocha | one-dark |+| catppuccin-latte | tokyo-night-storm | dracula |+| github-light | catppuccin-mocha | one-dark || solarized-light | github-dark | || | solarized-dark | |@@ -88,12 +88,15 @@ node scripts/batch.mjs \## 📂 Examples-Check the 5 template files in `assets/example_diagrams/`:+Check the 6 template files in `assets/example_diagrams/`:- `flowchart.mmd` - Flowchart- `sequence.mmd` - Sequence Diagram- `state.mmd` - State Diagram- `class.mmd` - Class Diagram- `er.mmd` - ER Diagram+- `xychart.mmd` - XY Chart (bar and line)++The renderer also supports CJK state names, multiline labels, `linkStyle`, configurable ELK layout spacing, interactive XY chart tooltips, and ANSI-colored terminal output.## 📚 DocumentationSee [SKILL.md](SKILL.md) for detailed usage guide.diff --git a/README_CN.md b/README_CN.mdindex e523c8e..97a839e 100644--- a/README_CN.md+++ b/README_CN.md@@ -23,7 +23,7 @@- 📊 **多格式支持**:支持 SVG 和 ASCII 渲染导出- 🎨 **丰富主题**:内置 15 种精美主题,满足不同场景需求-- 📈 **全图表支持**:支持 Flowchart, Sequence, State, Class, ER 等 5 种常用图表+- 📈 **六种图表类型**:支持 Flowchart、Sequence、State、Class、ER 和 XY Chart- ⚡ **高效渲染**:支持批量并行渲染,速度飞快- 📚 **开箱即用**:提供完整的模板和详细文档@@ -32,8 +32,8 @@| :--- | :--- | :--- || zinc-light | zinc-dark | nord || tokyo-night-light | tokyo-night | nord-light |-| cappuccin-latte | tokyo-night-storm | dracula |-| github-light | cappuccin-mocha | one-dark |+| catppuccin-latte | tokyo-night-storm | dracula |+| github-light | catppuccin-mocha | one-dark || solarized-light | github-dark | || | solarized-dark | |@@ -88,12 +88,15 @@ node scripts/batch.mjs \## 📂 使用示例-查看 `assets/example_diagrams/` 目录下的 5 个模板文件,快速上手:+查看 `assets/example_diagrams/` 目录下的 6 个模板文件,快速上手:- `flowchart.mmd` - 流程图- `sequence.mmd` - 时序图- `state.mmd` - 状态图- `class.mmd` - 类图- `er.mmd` - ER 图+- `xychart.mmd` - XY 图(柱状图与折线图)++渲染器同时支持中日韩状态名称、多行标签、`linkStyle`、可配置的 ELK 布局间距、XY 图交互提示,以及带 ANSI 颜色的终端输出。## 📚 完整文档详细使用指南请参阅 [SKILL.md](SKILL.md)diff --git a/SKILL.md b/SKILL.mdindex f344d46..4c0c042 100644--- a/SKILL.md+++ b/SKILL.md@@ -2,15 +2,15 @@name: pretty-mermaiddescription: |Render beautiful Mermaid diagrams as SVG or ASCII art using the beautiful-mermaid library.- Supports 15+ themes, 5 diagram types (flowchart, sequence, state, class, ER), and ultra-fast rendering.+ Supports 15 themes, 6 diagram types (flowchart, sequence, state, class, ER, XY charts), and ultra-fast rendering.Use this skill when:1. User asks to "render a mermaid diagram" or provides .mmd files- 2. User requests "create a flowchart/sequence diagram/state diagram"+ 2. User requests "create a flowchart/sequence/state/class/ER/XY chart"3. User wants to "apply a theme" or "beautify a diagram"4. User needs to "batch process multiple diagrams"5. User mentions "ASCII diagram" or "terminal-friendly diagram"- 6. User wants to visualize architecture, workflows, or data models+ 6. User wants to visualize architecture, workflows, data models, or chart data---# Pretty Mermaid@@ -51,7 +51,8 @@ node scripts/batch.mjs \node scripts/render.mjs \--input diagram.mmd \--format ascii \- --use-ascii+ --use-ascii \+ --color-mode none```---@@ -117,6 +118,7 @@ When user provides a `.mmd` file or Mermaid code block:- `--use-ascii` - Use pure ASCII (no Unicode)- `--padding-x 5` - Horizontal spacing- `--padding-y 5` - Vertical spacing+ - `--color-mode auto` - Terminal colors (`none`, `auto`, `ansi16`, `ansi256`, `truecolor`, or `html`)### Advanced Options@@ -146,6 +148,19 @@ node scripts/render.mjs \--output custom-font.svg```+**Layout and interactive XY charts**:+```bash+node scripts/render.mjs \+ --input chart.mmd \+ --node-spacing 32 \+ --layer-spacing 56 \+ --thoroughness 5 \+ --interactive \+ --output chart.svg+```++Use `--padding`, `--node-spacing`, `--layer-spacing`, and `--component-spacing` to tune ELK layout. `--interactive` enables hover tooltips for XY chart bars and points.+---## Creating Diagrams@@ -155,7 +170,7 @@ node scripts/render.mjs \**Step 1: List available templates**```bashls assets/example_diagrams/-# flowchart.mmd sequence.mmd state.mmd class.mmd er.mmd+# flowchart.mmd sequence.mmd state.mmd class.mmd er.mmd xychart.mmd```**Step 2: Copy and modify**@@ -215,6 +230,17 @@ erDiagramORDER ||--|{ ORDER_ITEM : contains```+**XY Chart** - Bar charts, line charts, trends, and comparisons+```mermaid+xychart-beta+ title "Monthly Revenue"+ x-axis [Jan, Feb, Mar]+ bar [3200, 4100, 3800]+ line [3000, 3700, 4200]+```++Flowcharts and state diagrams support `linkStyle`; state names may contain CJK text. SVG output supports `<br>` multiline labels and simple `<b>`, `<i>`, `<u>`, and `<s>` inline formatting.+### From User Requirements**Step 1: Identify diagram type**@@ -223,6 +249,7 @@ erDiagram- **States/lifecycle** → State- **Object model** → Class- **Database** → ER+- **Metrics/trends** → XY Chart**Step 2: Create diagram file**```bash@@ -265,10 +292,10 @@ Available Beautiful-Mermaid Themes:8. nord9. nord-light10. dracula-11. github-dark-12. github-light-13. solarized-dark-14. solarized-light+11. github-light+12. github-dark+13. solarized-light+14. solarized-dark15. one-darkTotal: 15 themes@@ -432,6 +459,16 @@ node scripts/render.mjs \--theme zinc-light```+### 6. Interactive Metrics Chart++```bash+node scripts/render.mjs \+ --input metrics.mmd \+ --output metrics.svg \+ --theme github-light \+ --interactive+```+---## Troubleshooting@@ -486,6 +523,7 @@ Template files for quick diagram creation:- `example_diagrams/state.mmd` - State diagram template- `example_diagrams/class.mmd` - Class diagram template- `example_diagrams/er.mmd` - ER diagram template+- `example_diagrams/xychart.mmd` - XY bar and line chart template---diff --git a/assets/example_diagrams/xychart.mmd b/assets/example_diagrams/xychart.mmdnew file mode 100644index 0000000..fd1ad2f--- /dev/null+++ b/assets/example_diagrams/xychart.mmd@@ -0,0 +1,6 @@+xychart-beta+ title "Monthly Revenue"+ x-axis [Jan, Feb, Mar, Apr, May, Jun]+ y-axis "Revenue" 0 --> 7000+ bar [3200, 4100, 3800, 5200, 4900, 6100]+ line [3000, 3700, 4200, 4600, 5300, 5900]diff --git a/package-lock.json b/package-lock.jsonnew file mode 100644index 0000000..a39d0f1--- /dev/null+++ b/package-lock.json@@ -0,0 +1,48 @@+{+ "name": "pretty-mermaid-skill",+ "version": "1.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "pretty-mermaid-skill",+ "version": "1.0.0",+ "dependencies": {+ "beautiful-mermaid": "^1.1.3"+ },+ "bin": {+ "batch-mermaid": "scripts/batch.mjs",+ "list-mermaid-themes": "scripts/themes.mjs",+ "render-mermaid": "scripts/render.mjs"+ }+ },+ "node_modules/beautiful-mermaid": {+ "version": "1.1.3",+ "resolved": "https://registry.npmjs.org/beautiful-mermaid/-/beautiful-mermaid-1.1.3.tgz",+ "integrity": "sha512-TItrtrAyHp1vwFfFVYauWGrquouk/6SS21Aq3RsxindSYZODcN4xYrPZD6BiZRU+o5mKJzDPz9MUSMvELdylyg==",+ "license": "MIT",+ "dependencies": {+ "elkjs": "^0.11.0",+ "entities": "^7.0.1"+ }+ },+ "node_modules/elkjs": {+ "version": "0.11.1",+ "resolved": "https://registry.npmjs.org/elkjs/-/elkjs-0.11.1.tgz",+ "integrity": "sha512-zxxR9k+rx5ktMwT/FwyLdPCrq7xN6e4VGGHH8hA01vVYKjTFik7nHOxBnAYtrgYUB1RpAiLvA1/U2YraWxyKKg==",+ "license": "EPL-2.0"+ },+ "node_modules/entities": {+ "version": "7.0.1",+ "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",+ "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=0.12"+ },+ "funding": {+ "url": "https://github.com/fb55/entities?sponsor=1"+ }+ }+ }+}diff --git a/package.json b/package.jsonindex 9dfa8d8..c5cc82a 100644--- a/package.json+++ b/package.json@@ -8,7 +8,10 @@"batch-mermaid": "./scripts/batch.mjs","list-mermaid-themes": "./scripts/themes.mjs"},+ "scripts": {+ "test": "node scripts/smoke-test.mjs"+ },"dependencies": {- "beautiful-mermaid": "^0.1.3"+ "beautiful-mermaid": "^1.1.3"}}diff --git a/references/DIAGRAM_TYPES.md b/references/DIAGRAM_TYPES.mdindex a0883ad..0084f5e 100644--- a/references/DIAGRAM_TYPES.md+++ b/references/DIAGRAM_TYPES.md@@ -31,6 +31,16 @@ flowchart LR- `--text-->` - Arrow with text- `-->|text|` - Arrow with text (alt syntax)+### Edge Styling+```mermaid+flowchart LR+ A --> B+ B --> C+ linkStyle 0 stroke:#7aa2f7,stroke-width:3px+```++`linkStyle` works in flowcharts and state diagrams. Target an edge by its zero-based declaration order, or use `linkStyle default` for all edges.+### Direction- `LR` - Left to Right- `RL` - Right to Left@@ -175,6 +185,7 @@ stateDiagram-v2- Limit composite state depth to 2 levels- Group related states together- Use choice nodes for complex branching+- State names and transition labels may contain Chinese, Japanese, Korean, and other Unicode text---@@ -294,6 +305,41 @@ erDiagram---+## XY Chart++### Bar and Line Series+```mermaid+xychart-beta+ title "Monthly Revenue"+ x-axis [Jan, Feb, Mar, Apr, May, Jun]+ y-axis "Revenue" 0 --> 7000+ bar [3200, 4100, 3800, 5200, 4900, 6100]+ line [3000, 3700, 4200, 4600, 5300, 5900]+```++### Horizontal Charts+```mermaid+xychart-beta horizontal+ title "Language Popularity"+ x-axis [Python, JavaScript, Java, Go, Rust]+ bar [30, 25, 20, 12, 8]+```++### Axis Configuration+- Categorical axis: `x-axis [A, B, C]`+- Numeric range: `x-axis 0 --> 100`+- Axis title: `y-axis "Score" 0 --> 100`+- Add multiple `bar` or `line` declarations for multi-series charts+- Pass `--interactive` when rendering SVG to enable hover tooltips++### Best Practices+- Keep category labels short enough to avoid crowding+- Set an explicit numeric range when series must be compared consistently+- Use a combined bar and line chart only when the two series share a meaningful scale+- Prefer ASCII output with `--color-mode none` for logs and stable snapshots++---+## General Best Practices### Themingdiff --git a/references/api_reference.md b/references/api_reference.mdindex 85392c8..5fe3757 100644--- a/references/api_reference.md+++ b/references/api_reference.md@@ -1,34 +1,55 @@-# Reference Documentation for Beautiful Mermaid--This is a placeholder for detailed reference documentation.-Replace with actual reference content or delete if not needed.--Example real reference docs from other skills:-- product-management/references/communication.md - Comprehensive guide for status updates-- product-management/references/context_building.md - Deep-dive on gathering context-- bigquery/references/ - API references and query examples--## When Reference Docs Are Useful--Reference docs are ideal for:-- Comprehensive API documentation-- Detailed workflow guides-- Complex multi-step processes-- Information too lengthy for main SKILL.md-- Content that's only needed for specific use cases--## Structure Suggestions--### API Reference Example-- Overview-- Authentication-- Endpoints with examples-- Error codes-- Rate limits--### Workflow Guide Example-- Prerequisites-- Step-by-step instructions-- Common patterns-- Troubleshooting-- Best practices+# beautiful-mermaid 1.1 API Reference++Use this reference when extending the bundled CLI scripts or calling `beautiful-mermaid` directly. The Skill currently targets `beautiful-mermaid@^1.1.3`.++## Rendering API++```js+import {+ renderMermaidSVG,+ renderMermaidSVGAsync,+ renderMermaidASCII,+ THEMES,+} from 'beautiful-mermaid';+```++- `renderMermaidSVG(text, options?)` returns an SVG string synchronously.+- `renderMermaidSVGAsync(text, options?)` returns the same SVG as a promise.+- `renderMermaidASCII(text, options?)` returns Unicode or plain ASCII terminal output.+- `THEMES` contains the 15 built-in color themes.+- `parseMermaid(text)` parses source into a graph for custom processing.+- `fromShikiTheme(theme)` converts a Shiki theme to diagram colors.++Legacy aliases `renderMermaid` and `renderMermaidAscii` still exist in 1.1.3, but new code should use the canonical names above.++## SVG Options++| Option | Default | Purpose |+| --- | --- | --- |+| `bg`, `fg` | zinc light colors | Base background and foreground colors |+| `line`, `accent`, `muted`, `surface`, `border` | derived | Optional enriched theme colors |+| `font` | `Inter` | Font family |+| `transparent` | `false` | Transparent SVG background |+| `padding` | `40` | Canvas padding in pixels |+| `nodeSpacing` | `24` | Horizontal spacing between sibling nodes |+| `layerSpacing` | `40` | Vertical spacing between layers |+| `componentSpacing` | `24` | Spacing between disconnected components |+| `thoroughness` | `3` | Crossing-minimization trials from 1 to 7 |+| `interactive` | `false` | Hover tooltips for XY chart bars and points |++## ASCII Options++| Option | Default | Purpose |+| --- | --- | --- |+| `useAscii` | `false` | Use plain ASCII instead of Unicode box drawing |+| `paddingX` | `5` | Horizontal node spacing |+| `paddingY` | `5` | Vertical node spacing |+| `boxBorderPadding` | `1` | Inner box padding |+| `colorMode` | `auto` | `none`, `auto`, `ansi16`, `ansi256`, `truecolor`, or `html` |+| `theme` | none | Partial ASCII role-color overrides |++## Supported Inputs++The renderer auto-detects flowcharts, sequence diagrams, state diagrams, class diagrams, ER diagrams, and `xychart-beta`. Version 1.1 also supports `linkStyle`, CJK state names, multiline labels, disconnected components, and per-subgraph direction overrides.++For exact upstream behavior, consult the [beautiful-mermaid README](https://github.com/lukilabs/beautiful-mermaid#readme) and [v1.x releases](https://github.com/lukilabs/beautiful-mermaid/releases).diff --git a/scripts/batch.mjs b/scripts/batch.mjsindex 7e4d154..74fe822 100644--- a/scripts/batch.mjs+++ b/scripts/batch.mjs@@ -1,7 +1,7 @@#!/usr/bin/env nodeimport { execSync } from 'child_process';-import { dirname, join, resolve } from 'path';+import { dirname, join } from 'path';import { fileURLToPath } from 'url';import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync } from 'fs';@@ -45,8 +45,24 @@ function parseArgs() {theme: null,bg: null,fg: null,+ line: null,+ accent: null,+ muted: null,+ surface: null,+ border: null,+ font: 'Inter',transparent: false,useAscii: false,+ paddingX: 5,+ paddingY: 5,+ boxBorderPadding: 1,+ colorMode: 'auto',+ padding: 40,+ nodeSpacing: 24,+ layerSpacing: 40,+ componentSpacing: 24,+ thoroughness: 3,+ interactive: false,workers: 4,};@@ -61,8 +77,24 @@ function parseArgs() {case '--theme': case '-t': opts.theme = val; i++; break;case '--bg': opts.bg = val; i++; break;case '--fg': opts.fg = val; i++; break;+ case '--line': opts.line = val; i++; break;+ case '--accent': opts.accent = val; i++; break;+ case '--muted': opts.muted = val; i++; break;+ case '--surface': opts.surface = val; i++; break;+ case '--border': opts.border = val; i++; break;+ case '--font': opts.font = val; i++; break;case '--transparent': opts.transparent = true; break;case '--use-ascii': opts.useAscii = true; break;+ case '--padding-x': opts.paddingX = parseInt(val); i++; break;+ case '--padding-y': opts.paddingY = parseInt(val); i++; break;+ case '--box-border-padding': opts.boxBorderPadding = parseInt(val); i++; break;+ case '--color-mode': opts.colorMode = val; i++; break;+ case '--padding': opts.padding = parseInt(val); i++; break;+ case '--node-spacing': opts.nodeSpacing = parseInt(val); i++; break;+ case '--layer-spacing': opts.layerSpacing = parseInt(val); i++; break;+ case '--component-spacing': opts.componentSpacing = parseInt(val); i++; break;+ case '--thoroughness': opts.thoroughness = parseInt(val); i++; break;+ case '--interactive': opts.interactive = true; break;case '--workers': case '-w': opts.workers = parseInt(val); i++; break;case '--help': case '-h':console.log(`Usage: node batch.mjs --input-dir <dir> --output-dir <dir> [options]@@ -74,8 +106,24 @@ Options:-t, --theme <name> Theme name (e.g. tokyo-night, dracula)--bg <hex> Background color--fg <hex> Foreground color+ --line <hex> Edge/connector color+ --accent <hex> Arrow heads and highlights color+ --muted <hex> Secondary text color+ --surface <hex> Node fill tint color+ --border <hex> Node stroke color+ --font <name> Font family (default: Inter)--transparent Transparent background (SVG only)--use-ascii Pure ASCII instead of Unicode (ASCII only)+ --padding-x <n> Horizontal spacing (ASCII only, default: 5)+ --padding-y <n> Vertical spacing (ASCII only, default: 5)+ --box-border-padding <n> Padding inside node boxes (ASCII only, default: 1)+ --color-mode <mode> ASCII colors: none | auto | ansi16 | ansi256 | truecolor | html+ --padding <n> SVG canvas padding in px (default: 40)+ --node-spacing <n> SVG horizontal node spacing (default: 24)+ --layer-spacing <n> SVG vertical layer spacing (default: 40)+ --component-spacing <n> SVG disconnected component spacing (default: 24)+ --thoroughness <n> SVG layout trials, 1-7 (default: 3)+ --interactive Enable XY chart hover tooltips (SVG only)-w, --workers <n> Parallel workers (default: 4)`);process.exit(0);}@@ -98,25 +146,43 @@ Options:}async function renderFile(file, inputDir, outputDir, opts, lib) {- const { renderMermaid, renderMermaidAscii, THEMES } = lib;+ const { renderMermaidSVG, renderMermaidASCII, THEMES } = lib;const inputPath = join(inputDir, file);const ext = opts.format === 'svg' ? '.svg' : '.txt';const outputPath = join(outputDir, file.replace(/\.mmd$/, ext));const input = readFileSync(inputPath, 'utf8');if (opts.format === 'ascii') {- const ascii = renderMermaidAscii(input, { useAscii: opts.useAscii });+ const ascii = renderMermaidASCII(input, {+ useAscii: opts.useAscii,+ paddingX: opts.paddingX,+ paddingY: opts.paddingY,+ boxBorderPadding: opts.boxBorderPadding,+ colorMode: opts.colorMode,+ });writeFileSync(outputPath, ascii);} else {const theme = opts.theme ? THEMES[opts.theme] : undefined;const colors = theme || {...(opts.bg && { bg: opts.bg }),...(opts.fg && { fg: opts.fg }),+ ...(opts.line && { line: opts.line }),+ ...(opts.accent && { accent: opts.accent }),+ ...(opts.muted && { muted: opts.muted }),+ ...(opts.surface && { surface: opts.surface }),+ ...(opts.border && { border: opts.border }),};- const svg = await renderMermaid(input, {+ const svg = renderMermaidSVG(input, {...colors,+ font: opts.font,transparent: opts.transparent,+ padding: opts.padding,+ nodeSpacing: opts.nodeSpacing,+ layerSpacing: opts.layerSpacing,+ componentSpacing: opts.componentSpacing,+ thoroughness: opts.thoroughness,+ interactive: opts.interactive,});writeFileSync(outputPath, svg);}@@ -126,6 +192,10 @@ async function main() {const opts = parseArgs();const lib = await loadBeautifulMermaid();+ if (opts.theme && !lib.THEMES[opts.theme]) {+ throw new Error(`Unknown theme: ${opts.theme}. Run node scripts/themes.mjs to list themes.`);+ }+mkdirSync(opts.outputDir, { recursive: true });const files = readdirSync(opts.inputDir).filter(f => f.endsWith('.mmd'));diff --git a/scripts/render.mjs b/scripts/render.mjsindex 3082c44..bb5bfb4 100644--- a/scripts/render.mjs+++ b/scripts/render.mjs@@ -1,7 +1,7 @@#!/usr/bin/env nodeimport { execSync } from 'child_process';-import { dirname, join, resolve } from 'path';+import { dirname, join } from 'path';import { fileURLToPath } from 'url';import { readFileSync, writeFileSync, existsSync } from 'fs';@@ -51,6 +51,13 @@ function parseArgs() {paddingX: 5,paddingY: 5,boxBorderPadding: 1,+ colorMode: 'auto',+ padding: 40,+ nodeSpacing: 24,+ layerSpacing: 40,+ componentSpacing: 24,+ thoroughness: 3,+ interactive: false,};for (let i = 0; i < args.length; i++) {@@ -75,6 +82,13 @@ function parseArgs() {case '--padding-x': opts.paddingX = parseInt(val); i++; break;case '--padding-y': opts.paddingY = parseInt(val); i++; break;case '--box-border-padding': opts.boxBorderPadding = parseInt(val); i++; break;+ case '--color-mode': opts.colorMode = val; i++; break;+ case '--padding': opts.padding = parseInt(val); i++; break;+ case '--node-spacing': opts.nodeSpacing = parseInt(val); i++; break;+ case '--layer-spacing': opts.layerSpacing = parseInt(val); i++; break;+ case '--component-spacing': opts.componentSpacing = parseInt(val); i++; break;+ case '--thoroughness': opts.thoroughness = parseInt(val); i++; break;+ case '--interactive': opts.interactive = true; break;case '--help': case '-h':console.log(`Usage: node render.mjs --input <file> [options]@@ -95,7 +109,14 @@ Options:--use-ascii Pure ASCII instead of Unicode (ASCII only)--padding-x <n> Horizontal spacing (ASCII only, default: 5)--padding-y <n> Vertical spacing (ASCII only, default: 5)- --box-border-padding <n> Padding inside node boxes (ASCII only, default: 1)`);+ --box-border-padding <n> Padding inside node boxes (ASCII only, default: 1)+ --color-mode <mode> ASCII colors: none | auto | ansi16 | ansi256 | truecolor | html+ --padding <n> SVG canvas padding in px (default: 40)+ --node-spacing <n> SVG horizontal node spacing (default: 24)+ --layer-spacing <n> SVG vertical layer spacing (default: 40)+ --component-spacing <n> SVG disconnected component spacing (default: 24)+ --thoroughness <n> SVG layout trials, 1-7 (default: 3)+ --interactive Enable XY chart hover tooltips (SVG only)`);process.exit(0);}}@@ -115,15 +136,20 @@ Options:async function main() {const opts = parseArgs();- const { renderMermaid, renderMermaidAscii, THEMES } = await loadBeautifulMermaid();+ const { renderMermaidSVG, renderMermaidASCII, THEMES } = await loadBeautifulMermaid();const input = readFileSync(opts.input, 'utf8');+ if (opts.theme && !THEMES[opts.theme]) {+ throw new Error(`Unknown theme: ${opts.theme}. Run node scripts/themes.mjs to list themes.`);+ }+if (opts.format === 'ascii') {- const ascii = renderMermaidAscii(input, {+ const ascii = renderMermaidASCII(input, {useAscii: opts.useAscii,paddingX: opts.paddingX,paddingY: opts.paddingY,boxBorderPadding: opts.boxBorderPadding,+ colorMode: opts.colorMode,});if (opts.output) {writeFileSync(opts.output, ascii);@@ -143,10 +169,16 @@ async function main() {...(opts.border && { border: opts.border }),};- const svg = await renderMermaid(input, {+ const svg = renderMermaidSVG(input, {...colors,font: opts.font,transparent: opts.transparent,+ padding: opts.padding,+ nodeSpacing: opts.nodeSpacing,+ layerSpacing: opts.layerSpacing,+ componentSpacing: opts.componentSpacing,+ thoroughness: opts.thoroughness,+ interactive: opts.interactive,});if (opts.output) {diff --git a/scripts/smoke-test.mjs b/scripts/smoke-test.mjsnew file mode 100644index 0000000..6135390--- /dev/null+++ b/scripts/smoke-test.mjs@@ -0,0 +1,29 @@+#!/usr/bin/env node++import assert from 'node:assert/strict';+import { readdirSync, readFileSync } from 'node:fs';+import { dirname, join } from 'node:path';+import { fileURLToPath } from 'node:url';+import {+ renderMermaidASCII,+ renderMermaidSVG,+ THEMES,+} from 'beautiful-mermaid';++const scriptsDir = dirname(fileURLToPath(import.meta.url));+const examplesDir = join(scriptsDir, '..', 'assets', 'example_diagrams');+const files = readdirSync(examplesDir).filter(file => file.endsWith('.mmd')).sort();++assert.equal(files.length, 6, 'Expected six example diagrams');+assert.equal(Object.keys(THEMES).length, 15, 'Expected 15 built-in themes');++for (const file of files) {+ const source = readFileSync(join(examplesDir, file), 'utf8');+ const svg = renderMermaidSVG(source, THEMES['tokyo-night']);+ const ascii = renderMermaidASCII(source, { colorMode: 'none' });++ assert.ok(svg.startsWith('<svg'), `${file} did not render valid SVG`);+ assert.ok(ascii.trim().length > 0, `${file} did not render ASCII output`);+}++console.log(`Smoke tests passed: ${files.length} diagrams x 2 formats, 15 themes.`);