zombie-mermaid 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +153 -0
- package/dist/cli.js +11194 -0
- package/dist/index.cjs +11060 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +344 -0
- package/dist/index.d.ts +344 -0
- package/dist/index.js +11014 -0
- package/dist/index.js.map +1 -0
- package/package.json +104 -0
- package/src/__tests__/ascii-ansi.test.ts +498 -0
- package/src/__tests__/ascii-canvas-write.test.ts +137 -0
- package/src/__tests__/ascii-charset-border-junctions.test.ts +63 -0
- package/src/__tests__/ascii-cjk-width.test.ts +185 -0
- package/src/__tests__/ascii-class-diagram-compartments.test.ts +70 -0
- package/src/__tests__/ascii-decision-lr-box-start.test.ts +106 -0
- package/src/__tests__/ascii-draw-arrows-coverage.test.ts +171 -0
- package/src/__tests__/ascii-draw-arrows-single-point-path.test.ts +105 -0
- package/src/__tests__/ascii-draw-bundles.test.ts +638 -0
- package/src/__tests__/ascii-edge-bundling-routing.test.ts +210 -0
- package/src/__tests__/ascii-edge-routing-fixes.test.ts +178 -0
- package/src/__tests__/ascii-edge-routing-single-point-path.test.ts +103 -0
- package/src/__tests__/ascii-edge-styles.test.ts +149 -0
- package/src/__tests__/ascii-er-cardinality.test.ts +40 -0
- package/src/__tests__/ascii-er-label-padding.test.ts +118 -0
- package/src/__tests__/ascii-grid-deep-chain.test.ts +64 -0
- package/src/__tests__/ascii-multiline.test.ts +288 -0
- package/src/__tests__/ascii-pathfinder-route-edge.test.ts +184 -0
- package/src/__tests__/ascii-sequence-notes.test.ts +25 -0
- package/src/__tests__/ascii-sequence-self-arrow.test.ts +128 -0
- package/src/__tests__/ascii-shape-diamond.test.ts +38 -0
- package/src/__tests__/ascii-shape-rectangle.test.ts +258 -0
- package/src/__tests__/ascii-shape-rounded.test.ts +36 -0
- package/src/__tests__/ascii-shapes-circle.test.ts +41 -0
- package/src/__tests__/ascii-shapes-hexagon.test.ts +42 -0
- package/src/__tests__/ascii-shapes-special.test.ts +296 -0
- package/src/__tests__/ascii-shapes-stadium.test.ts +217 -0
- package/src/__tests__/ascii-shapes-state.test.ts +224 -0
- package/src/__tests__/ascii-subgraph-bbox.test.ts +135 -0
- package/src/__tests__/ascii-subgraph-label-border-clip.test.ts +89 -0
- package/src/__tests__/ascii-subgraph-title-padding.test.ts +77 -0
- package/src/__tests__/ascii-validate.test.ts +220 -0
- package/src/__tests__/ascii.test.ts +325 -0
- package/src/__tests__/browser.test.ts +34 -0
- package/src/__tests__/class-arrow-directions.test.ts +413 -0
- package/src/__tests__/class-integration.test.ts +118 -0
- package/src/__tests__/class-parser.test.ts +241 -0
- package/src/__tests__/cli-diagrams.test.ts +101 -0
- package/src/__tests__/cli-e2e.test.ts +213 -0
- package/src/__tests__/cli-entrypoint.test.ts +146 -0
- package/src/__tests__/cli-render.test.ts +175 -0
- package/src/__tests__/cli-test-helpers.ts +26 -0
- package/src/__tests__/cli.test.ts +204 -0
- package/src/__tests__/diagram-type.test.ts +28 -0
- package/src/__tests__/draw-lines.test.ts +93 -0
- package/src/__tests__/edge-approach-direction.test.ts +295 -0
- package/src/__tests__/er-integration.test.ts +528 -0
- package/src/__tests__/er-parser.test.ts +297 -0
- package/src/__tests__/grid-occupancy.test.ts +80 -0
- package/src/__tests__/integration.test.ts +595 -0
- package/src/__tests__/layout-disconnected.test.ts +384 -0
- package/src/__tests__/layout-engine.test.ts +88 -0
- package/src/__tests__/linkstyle.test.ts +133 -0
- package/src/__tests__/multiline-labels.test.ts +912 -0
- package/src/__tests__/nested-subgraph-direction-crossing.test.ts +304 -0
- package/src/__tests__/parser.test.ts +1187 -0
- package/src/__tests__/pathfinder.test.ts +239 -0
- package/src/__tests__/render-options-overrides.test.ts +250 -0
- package/src/__tests__/renderer.test.ts +743 -0
- package/src/__tests__/sequence-integration.test.ts +121 -0
- package/src/__tests__/sequence-layout.test.ts +861 -0
- package/src/__tests__/sequence-parser.test.ts +313 -0
- package/src/__tests__/styles.test.ts +201 -0
- package/src/__tests__/testdata/ascii/ampersand_lhs.txt +18 -0
- package/src/__tests__/testdata/ascii/ampersand_lhs_and_rhs.txt +18 -0
- package/src/__tests__/testdata/ascii/ampersand_rhs.txt +18 -0
- package/src/__tests__/testdata/ascii/ampersand_td_fanin.txt +18 -0
- package/src/__tests__/testdata/ascii/ampersand_td_fanout.txt +18 -0
- package/src/__tests__/testdata/ascii/ampersand_without_edge.txt +18 -0
- package/src/__tests__/testdata/ascii/back_reference_from_child.txt +10 -0
- package/src/__tests__/testdata/ascii/backlink_from_bottom.txt +22 -0
- package/src/__tests__/testdata/ascii/backlink_from_top.txt +22 -0
- package/src/__tests__/testdata/ascii/backlink_with_short_y_padding.txt +20 -0
- package/src/__tests__/testdata/ascii/cls_all_relationships.txt +17 -0
- package/src/__tests__/testdata/ascii/cls_annotation.txt +29 -0
- package/src/__tests__/testdata/ascii/cls_association.txt +14 -0
- package/src/__tests__/testdata/ascii/cls_basic.txt +15 -0
- package/src/__tests__/testdata/ascii/cls_dependency.txt +14 -0
- package/src/__tests__/testdata/ascii/cls_inheritance.txt +20 -0
- package/src/__tests__/testdata/ascii/cls_methods.txt +21 -0
- package/src/__tests__/testdata/ascii/comments.txt +23 -0
- package/src/__tests__/testdata/ascii/custom_padding.txt +10 -0
- package/src/__tests__/testdata/ascii/duplicate_labels.txt +19 -0
- package/src/__tests__/testdata/ascii/er_attributes.txt +21 -0
- package/src/__tests__/testdata/ascii/er_basic.txt +8 -0
- package/src/__tests__/testdata/ascii/er_identifying.txt +18 -0
- package/src/__tests__/testdata/ascii/flowchart_tb_simple.txt +29 -0
- package/src/__tests__/testdata/ascii/graph_bt_direction.txt +28 -0
- package/src/__tests__/testdata/ascii/graph_tb_direction.txt +26 -0
- package/src/__tests__/testdata/ascii/nested_subgraphs_with_labels.txt +36 -0
- package/src/__tests__/testdata/ascii/preserve_order_of_definition.txt +23 -0
- package/src/__tests__/testdata/ascii/self_reference.txt +10 -0
- package/src/__tests__/testdata/ascii/self_reference_with_edge.txt +10 -0
- package/src/__tests__/testdata/ascii/seq_basic.txt +17 -0
- package/src/__tests__/testdata/ascii/seq_multiple_messages.txt +25 -0
- package/src/__tests__/testdata/ascii/seq_self_message.txt +18 -0
- package/src/__tests__/testdata/ascii/single_node.txt +8 -0
- package/src/__tests__/testdata/ascii/single_node_longer_name.txt +8 -0
- package/src/__tests__/testdata/ascii/subgraph_complex_mixed.txt +38 -0
- package/src/__tests__/testdata/ascii/subgraph_complex_nested.txt +49 -0
- package/src/__tests__/testdata/ascii/subgraph_direction_override.txt +37 -0
- package/src/__tests__/testdata/ascii/subgraph_empty.txt +10 -0
- package/src/__tests__/testdata/ascii/subgraph_mixed_nodes.txt +20 -0
- package/src/__tests__/testdata/ascii/subgraph_mixed_nodes_td.txt +48 -0
- package/src/__tests__/testdata/ascii/subgraph_multiple_edges.txt +32 -0
- package/src/__tests__/testdata/ascii/subgraph_multiple_nodes.txt +16 -0
- package/src/__tests__/testdata/ascii/subgraph_nested.txt +24 -0
- package/src/__tests__/testdata/ascii/subgraph_nested_with_external.txt +30 -0
- package/src/__tests__/testdata/ascii/subgraph_node_outside_lr.txt +17 -0
- package/src/__tests__/testdata/ascii/subgraph_single_node.txt +16 -0
- package/src/__tests__/testdata/ascii/subgraph_td_direction.txt +26 -0
- package/src/__tests__/testdata/ascii/subgraph_td_multiple.txt +44 -0
- package/src/__tests__/testdata/ascii/subgraph_td_multiple_paddingy.txt +42 -0
- package/src/__tests__/testdata/ascii/subgraph_three_levels_nested.txt +32 -0
- package/src/__tests__/testdata/ascii/subgraph_three_separate.txt +24 -0
- package/src/__tests__/testdata/ascii/subgraph_two_separate.txt +20 -0
- package/src/__tests__/testdata/ascii/subgraph_with_labels.txt +20 -0
- package/src/__tests__/testdata/ascii/three_nodes.txt +9 -0
- package/src/__tests__/testdata/ascii/three_nodes_single_line.txt +8 -0
- package/src/__tests__/testdata/ascii/two_layer_single_graph.txt +19 -0
- package/src/__tests__/testdata/ascii/two_layer_single_graph_longer_names.txt +19 -0
- package/src/__tests__/testdata/ascii/two_nodes_linked.txt +8 -0
- package/src/__tests__/testdata/ascii/two_nodes_longer_names.txt +8 -0
- package/src/__tests__/testdata/ascii/two_root_nodes.txt +19 -0
- package/src/__tests__/testdata/ascii/two_root_nodes_longer_names.txt +19 -0
- package/src/__tests__/testdata/ascii/two_single_root_nodes.txt +19 -0
- package/src/__tests__/testdata/unicode/ampersand_lhs.txt +18 -0
- package/src/__tests__/testdata/unicode/ampersand_lhs_and_rhs.txt +18 -0
- package/src/__tests__/testdata/unicode/ampersand_rhs.txt +18 -0
- package/src/__tests__/testdata/unicode/ampersand_without_edge.txt +18 -0
- package/src/__tests__/testdata/unicode/back_reference_from_child.txt +10 -0
- package/src/__tests__/testdata/unicode/backlink_from_bottom.txt +22 -0
- package/src/__tests__/testdata/unicode/backlink_from_top.txt +22 -0
- package/src/__tests__/testdata/unicode/cls_all_relationships.txt +17 -0
- package/src/__tests__/testdata/unicode/cls_annotation.txt +29 -0
- package/src/__tests__/testdata/unicode/cls_association.txt +14 -0
- package/src/__tests__/testdata/unicode/cls_basic.txt +15 -0
- package/src/__tests__/testdata/unicode/cls_dependency.txt +14 -0
- package/src/__tests__/testdata/unicode/cls_inheritance.txt +20 -0
- package/src/__tests__/testdata/unicode/cls_methods.txt +21 -0
- package/src/__tests__/testdata/unicode/comments.txt +23 -0
- package/src/__tests__/testdata/unicode/duplicate_labels.txt +19 -0
- package/src/__tests__/testdata/unicode/er_attributes.txt +21 -0
- package/src/__tests__/testdata/unicode/er_basic.txt +8 -0
- package/src/__tests__/testdata/unicode/er_identifying.txt +18 -0
- package/src/__tests__/testdata/unicode/graph_bt_direction.txt +28 -0
- package/src/__tests__/testdata/unicode/preserve_order_of_definition.txt +23 -0
- package/src/__tests__/testdata/unicode/self_reference.txt +10 -0
- package/src/__tests__/testdata/unicode/self_reference_with_edge.txt +10 -0
- package/src/__tests__/testdata/unicode/seq_basic.txt +17 -0
- package/src/__tests__/testdata/unicode/seq_multiple_messages.txt +25 -0
- package/src/__tests__/testdata/unicode/seq_self_message.txt +18 -0
- package/src/__tests__/testdata/unicode/single_node.txt +8 -0
- package/src/__tests__/testdata/unicode/single_node_longer_name.txt +8 -0
- package/src/__tests__/testdata/unicode/three_nodes.txt +9 -0
- package/src/__tests__/testdata/unicode/three_nodes_single_line.txt +8 -0
- package/src/__tests__/testdata/unicode/two_layer_single_graph.txt +19 -0
- package/src/__tests__/testdata/unicode/two_layer_single_graph_longer_names.txt +19 -0
- package/src/__tests__/testdata/unicode/two_nodes_linked.txt +8 -0
- package/src/__tests__/testdata/unicode/two_nodes_longer_names.txt +8 -0
- package/src/__tests__/testdata/unicode/two_root_nodes.txt +19 -0
- package/src/__tests__/testdata/unicode/two_root_nodes_longer_names.txt +19 -0
- package/src/__tests__/testdata/unicode/two_single_root_nodes.txt +19 -0
- package/src/__tests__/text-metrics.test.ts +298 -0
- package/src/__tests__/theme.test.ts +108 -0
- package/src/__tests__/xychart-ascii.test.ts +327 -0
- package/src/__tests__/xychart-colors.test.ts +148 -0
- package/src/__tests__/xychart-integration.test.ts +137 -0
- package/src/__tests__/xychart-layout.test.ts +167 -0
- package/src/ascii/ansi.ts +500 -0
- package/src/ascii/canvas.ts +633 -0
- package/src/ascii/class-diagram.ts +765 -0
- package/src/ascii/converter.ts +393 -0
- package/src/ascii/display-width.ts +65 -0
- package/src/ascii/draw-arrows.ts +468 -0
- package/src/ascii/draw-boxes.ts +231 -0
- package/src/ascii/draw-bundles.ts +488 -0
- package/src/ascii/draw-lines.ts +165 -0
- package/src/ascii/draw-subgraphs.ts +93 -0
- package/src/ascii/draw.ts +303 -0
- package/src/ascii/edge-bundling.ts +343 -0
- package/src/ascii/edge-routing.ts +431 -0
- package/src/ascii/er-diagram.ts +565 -0
- package/src/ascii/grid-occupancy.ts +136 -0
- package/src/ascii/grid.ts +894 -0
- package/src/ascii/index.ts +166 -0
- package/src/ascii/multiline-utils.ts +82 -0
- package/src/ascii/pathfinder.ts +446 -0
- package/src/ascii/sequence.ts +578 -0
- package/src/ascii/shapes/circle.ts +31 -0
- package/src/ascii/shapes/corners.ts +130 -0
- package/src/ascii/shapes/diamond.ts +31 -0
- package/src/ascii/shapes/hexagon.ts +31 -0
- package/src/ascii/shapes/index.ts +119 -0
- package/src/ascii/shapes/rectangle.ts +199 -0
- package/src/ascii/shapes/rounded.ts +31 -0
- package/src/ascii/shapes/special.ts +310 -0
- package/src/ascii/shapes/stadium.ts +122 -0
- package/src/ascii/shapes/state.ts +204 -0
- package/src/ascii/shapes/types.ts +78 -0
- package/src/ascii/types.ts +373 -0
- package/src/ascii/validate.ts +189 -0
- package/src/ascii/xychart.ts +1060 -0
- package/src/browser.ts +36 -0
- package/src/class/layout.ts +274 -0
- package/src/class/parser.ts +347 -0
- package/src/class/renderer.ts +449 -0
- package/src/class/types.ts +121 -0
- package/src/cli/parse-args.ts +121 -0
- package/src/cli/render.ts +101 -0
- package/src/cli.ts +82 -0
- package/src/diagram-type.ts +32 -0
- package/src/elk-instance.ts +159 -0
- package/src/er/layout.ts +229 -0
- package/src/er/parser.ts +253 -0
- package/src/er/renderer.ts +474 -0
- package/src/er/types.ts +99 -0
- package/src/index.ts +174 -0
- package/src/layout-engine/constants.ts +19 -0
- package/src/layout-engine/edge-bundling.ts +287 -0
- package/src/layout-engine/from-elk.ts +616 -0
- package/src/layout-engine/layer-alignment.ts +170 -0
- package/src/layout-engine/to-elk.ts +645 -0
- package/src/layout-engine.ts +70 -0
- package/src/layout.ts +8 -0
- package/src/multiline-utils.ts +246 -0
- package/src/parser.ts +833 -0
- package/src/renderer.ts +810 -0
- package/src/sequence/layout.ts +561 -0
- package/src/sequence/parser.ts +283 -0
- package/src/sequence/renderer.ts +410 -0
- package/src/sequence/types.ts +146 -0
- package/src/shape-clipping.ts +197 -0
- package/src/styles.ts +118 -0
- package/src/text-metrics.ts +291 -0
- package/src/theme.ts +498 -0
- package/src/types.ts +198 -0
- package/src/xychart/colors.ts +177 -0
- package/src/xychart/layout.ts +682 -0
- package/src/xychart/parser.ts +125 -0
- package/src/xychart/renderer.ts +657 -0
- package/src/xychart/types.ts +150 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Craft Docs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# zombie-mermaid
|
|
4
|
+
|
|
5
|
+
**Render Mermaid diagrams as beautiful SVGs or ASCII art**
|
|
6
|
+
|
|
7
|
+
Ultra-fast, fully themeable, zero DOM dependencies. A maintained fork of [`beautiful-mermaid`](https://github.com/lukilabs/beautiful-mermaid).
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
[**Live demo →**](https://dfadler.github.io/zombie-mermaid/)
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/zombie-mermaid)
|
|
14
|
+
[](LICENSE)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Why This Fork Exists
|
|
21
|
+
|
|
22
|
+
`beautiful-mermaid` is a genuinely good library — see "Why We Built This" below — but upstream development has stalled: as of this writing there are 30 open pull requests, the oldest dating back over half a year, and nothing has merged in months. `zombie-mermaid` is the same codebase, kept moving: upstream fixes get pulled in, PRs stuck in the upstream queue get a home, and releases actually ship.
|
|
23
|
+
|
|
24
|
+
It's still MIT-licensed, still built on the same foundation, and still credits the original authors below.
|
|
25
|
+
|
|
26
|
+
## Why We Built This
|
|
27
|
+
|
|
28
|
+
Diagrams are essential for AI-assisted programming. When you're working with an AI coding assistant, being able to visualize data flows, state machines, and system architecture—directly in your terminal or chat interface—makes complex concepts instantly graspable.
|
|
29
|
+
|
|
30
|
+
[Mermaid](https://mermaid.js.org/) is the de facto standard for text-based diagrams. It's brilliant. But the default renderer has problems:
|
|
31
|
+
|
|
32
|
+
- **Aesthetics** — Might be personal preference, but wished they looked more professional
|
|
33
|
+
- **Complex theming** — Customizing colors requires wrestling with CSS classes
|
|
34
|
+
- **No terminal output** — Can't render to ASCII for CLI tools
|
|
35
|
+
- **Heavy dependencies** — Pulls in a lot of code for simple diagrams
|
|
36
|
+
|
|
37
|
+
We built `beautiful-mermaid` at [Craft](https://craft.do) to power diagrams in [Craft Agents](https://agents.craft.do). It's fast, beautiful, and works everywhere—from rich UIs to plain terminals.
|
|
38
|
+
|
|
39
|
+
The ASCII rendering engine is based on [mermaid-ascii](https://github.com/AlexanderGrooff/mermaid-ascii) by Alexander Grooff. We ported it from Go to TypeScript and extended it. Thank you Alexander for the excellent foundation! (And inspiration that this was possible.)
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **6 diagram types** — Flowcharts, State, Sequence, Class, ER, and XY Charts (bar, line, combined)
|
|
44
|
+
- **Dual output** — SVG for rich UIs, ASCII/Unicode for terminals
|
|
45
|
+
- **Synchronous rendering** — No async, no flash. Works with React `useMemo()`
|
|
46
|
+
- **15 built-in themes** — And dead simple to add your own
|
|
47
|
+
- **Full Shiki compatibility** — Use any VS Code theme directly
|
|
48
|
+
- **Live theme switching** — CSS custom properties, no re-render needed
|
|
49
|
+
- **Mono mode** — Beautiful diagrams from just 2 colors
|
|
50
|
+
- **Zero DOM dependencies** — Pure TypeScript, works everywhere
|
|
51
|
+
- **Ultra-fast** — Renders 100+ diagrams in under 500ms
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install zombie-mermaid
|
|
57
|
+
# or
|
|
58
|
+
bun add zombie-mermaid
|
|
59
|
+
# or
|
|
60
|
+
pnpm add zombie-mermaid
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### SVG Output
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { renderMermaidSVG } from 'zombie-mermaid'
|
|
69
|
+
|
|
70
|
+
const svg = renderMermaidSVG(`
|
|
71
|
+
graph TD
|
|
72
|
+
A[Start] --> B{Decision}
|
|
73
|
+
B -->|Yes| C[Action]
|
|
74
|
+
B -->|No| D[End]
|
|
75
|
+
`)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Rendering is **fully synchronous** — no `await`, no promises. The ELK.js layout engine runs synchronously via a FakeWorker bypass, so you get your SVG string instantly.
|
|
79
|
+
|
|
80
|
+
Need async? Use `renderMermaidSVGAsync()` — same output, returns a `Promise<string>`.
|
|
81
|
+
|
|
82
|
+
### ASCII Output
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { renderMermaidASCII } from 'zombie-mermaid'
|
|
86
|
+
|
|
87
|
+
const ascii = renderMermaidASCII(`graph LR; A --> B --> C`)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
┌───┐ ┌───┐ ┌───┐
|
|
92
|
+
│ │ │ │ │ │
|
|
93
|
+
│ A │────►│ B │────►│ C │
|
|
94
|
+
│ │ │ │ │ │
|
|
95
|
+
└───┘ └───┘ └───┘
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Using this from React? See [React Integration](docs/react-integration.md) for a zero-flash `useMemo()` pattern.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## CLI
|
|
103
|
+
|
|
104
|
+
Installing the package also exposes a `zombie-mermaid` binary:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
zombie-mermaid render diagram.mmd --ascii # Print ASCII/Unicode to terminal
|
|
108
|
+
zombie-mermaid render diagram.mmd --svg -o out.svg # Render to an SVG file
|
|
109
|
+
cat diagram.mmd | zombie-mermaid render --ascii # Read from stdin
|
|
110
|
+
zombie-mermaid themes # List built-in theme names
|
|
111
|
+
zombie-mermaid --help # Show all options
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`--theme <name>` applies a built-in theme (from `themes`) to either output mode.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Docs
|
|
119
|
+
|
|
120
|
+
- [Theming](docs/theming.md) — the two-color foundation, enriched mode, built-in themes, custom themes, Shiki compatibility
|
|
121
|
+
- [Supported Diagrams](docs/diagrams.md) — syntax for every diagram type, XY chart styling, and ASCII rendering options
|
|
122
|
+
- [React Integration](docs/react-integration.md) — zero-flash rendering with `useMemo()`
|
|
123
|
+
- [API Reference](docs/api-reference.md) — full function and options reference
|
|
124
|
+
|
|
125
|
+
More design write-ups and reference material live in [docs/](docs/).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Attribution
|
|
130
|
+
|
|
131
|
+
The ASCII rendering engine is based on [mermaid-ascii](https://github.com/AlexanderGrooff/mermaid-ascii) by Alexander Grooff. We ported it from Go to TypeScript and extended it with:
|
|
132
|
+
|
|
133
|
+
- Sequence diagram support
|
|
134
|
+
- Class diagram support
|
|
135
|
+
- ER diagram support
|
|
136
|
+
- Unicode box-drawing characters
|
|
137
|
+
- Configurable spacing and padding
|
|
138
|
+
|
|
139
|
+
Thank you Alexander for the excellent foundation!
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
<div align="center">
|
|
150
|
+
|
|
151
|
+
Built with care by the team at [Craft](https://craft.do)
|
|
152
|
+
|
|
153
|
+
</div>
|