moomaid
v0.1.0
Published
Mermaid diagram renderer for MoonBit (ASCII and SVG output)
Maintainers
Readme
moomaid
Mermaid diagram renderer written in MoonBit. Outputs ASCII art or SVG.
Install
moon add mizchi/moomaidCLI
# Render from file
just cli diagram.mmd
just cli --svg diagram.mmd
# Render from stdin
echo 'graph LR
A --> B --> C' | just cli-stdin
# Sequence diagram from stdin
cat <<EOF | just cli-stdin
sequenceDiagram
participant Client
participant API
participant DB
Client->>API: Request
API->>DB: Query
DB-->>API: Result
API-->>Client: Response
EOFOptions
--svg Output SVG (default: ASCII)
--ascii Output ASCII art
--width <n> Max width for ASCII (default: 80)
--help Show helpDiagram Types
Flowchart (graph LR / graph TD)
Use for visualizing data flow, module dependencies, and process graphs.
graph LR
Input --> Process --> Outputgraph TD
Start[Start] --> Auth{Auth}
Auth -->|pass| Load[Load Data]
Auth -->|fail| Error[Error Page]
Load --> Validate{Validate}
Validate -->|ok| Process[Process]
Validate -->|ng| Error
Process --> Save[Save]
Save --> Done[Done]
Error --> DoneSequence Diagram (sequenceDiagram)
Use for describing layer boundaries and API call flows.
sequenceDiagram
participant Browser
participant API
participant Auth
participant DB
Browser->>API: POST /login
API->>Auth: Validate token
Auth-->>API: OK
API->>DB: SELECT user
DB-->>API: User data
API-->>Browser: 200 JSONOther supported types
stateDiagram-v2- State machine diagramsclassDiagram- Class diagrams
Library Usage
// ASCII output
let ascii = @moomaid.render_to_string("graph LR\n A --> B")
// ASCII with options
let options : @moomaid.Options = {
use_ascii: false,
padding_x: 2,
padding_y: 1,
box_border_padding: 1,
max_width: 80,
}
let ascii2 = @moomaid.render_to_string("graph LR\n A --> B", options~)
// SVG output (experimental)
let svg = @moomaid.experimental_render_to_svg("graph LR\n A --> B")TUI Viewer
Interactive terminal viewer with tab switching and Kitty graphics protocol support.
just tuiTab/Shift+Tab: Switch diagramsUp/Down: Scrolls: Toggle ASCII / SVG mode (Kitty-compatible terminals)q: Quit
License
Apache-2.0
