A port of Mermaid (text-to-diagram toolkit) to MoonBit
///|
test {
let svg = @mermaid.render(
(
#|pie title Pets adopted by volunteers
#| "Dogs" : 386
#| "Cats" : 85
#| "Rats" : 15
),
)
assert_true(svg.has_prefix("<svg id=\"mermaid-svg\""))
assert_true(svg.contains("Pets adopted by volunteers"))
}| Diagram | State |
|---|---|
| Pie | byte-identical |
| Packet | byte-identical |
| Info | byte-identical |
| Flowchart | byte-identical with the ELK and dagre layouts; see below |
| Git graph | byte-identical, all orientations and options; upstream's documentation examples match |
| Entity relationship | byte-identical with the ELK and dagre layouts |
| Requirement | byte-identical with the ELK and dagre layouts |
| State | byte-identical with the ELK and dagre layouts, stateDiagram and stateDiagram-v2 |
| Class | byte-identical with the ELK and dagre layouts, including cardinalities, namespaces and notes |
| User journey | byte-identical, all journey: options |
| Timeline | byte-identical, horizontal and vertical, both looks |
| Gantt | byte-identical; see the note on time below |
| Sequence | byte-identical: all participant kinds and arrow types, both looks; KaTeX is not ported |
| Sankey | byte-identical, all sankey: options |
| Radar | byte-identical |
| Treemap | byte-identical; depends on the page like Gantt charts |
| Block | byte-identical: grid layout, block arrows, all edge curves |
| C4 | byte-identical: all five kinds, boundaries, relationships, style updates |
| Quadrant chart | byte-identical |
| XY chart | byte-identical, both orientations; depends on the page like Gantt charts |
| Tree view | byte-identical; emoji labels are refused |
| Ishikawa | byte-identical, including the hand-drawn look with a seed |
| Cynefin | byte-identical |
| Railroad | byte-identical, all four front ends (railroad, EBNF, ABNF, PEG) |
| Event modeling | byte-identical |
| Wardley map | byte-identical |
| Agentflow | byte-identical with the ELK and dagre layouts, including collapsed containers |
| Kanban | byte-identical, including the hand-drawn look |
| Use case | byte-identical with the ELK and dagre layouts |
| Mindmap | byte-identical with its default cose-bilkent layout (internal/cose) and with dagre |
| Swimlanes | byte-identical, with the swimlane layout engine (internal/swimlane) |
| Architecture | byte-identical, with the fcose layout (internal/fcose) |
| Venn | byte-identical, including the hand-drawn look; the layout optimiser of venn.js is transcribed step by step |
| Package | Role |
|---|---|
| moonbit-community/mermaid | render |
| config, theme | configuration and theme variables |
| diagram | the context renderers draw into |
| diagrams/* | one package per diagram type |
| internal/rendering | the unified renderer for diagrams of nodes, edges and groups |
| internal/rough | the part of rough.js mermaid draws shapes with |
| internal/* | color math, CSS, DOM, d3 helpers, fonts, math, regex, parser runtimes, preprocessing |
| cmd/mermaid | native CLI: mermaid render file.mmd |
impl Show for MermaidErrorfn render(text : String, id? : String, config? : Json, now? : Double, page? : Page, image_loader? : (String) -> Bytes?) -> String raise MermaidError