Generate diagrams from text using Mermaid.
@mermaid-js/mermaid-cli (npm install -g @mermaid-js/mermaid-cli).mmd filemmdc to render PNG/SVGmmdc -i input.mmd -o output.png -t dark -b transparent
| Flag | Description |
|---|---|
| --- | --- |
-i | Input .mmd file |
-o | Output file (.png, .svg, .pdf) |
-t | Theme: default, dark, forest, neutral |
-b | Background color (transparent, hex) |
-w | Width in pixels (default: 800) |
-H | Height in pixels |
-s | Scale factor (default: 1, use 2-3 for high-res) |
-c | Config JSON file for advanced theming |
graph TD / graph LRsequenceDiagramclassDiagramstateDiagram-v2erDiagramganttpiemindmaptimelinegitGraphquadrantChartblock-beta.mmd file to /tmp/mermaid-.mmd mmdc -i /tmp/mermaid-.mmd -o /tmp/mermaid-.png -t dark -b transparent -s 2 Read toolgraph TD
A[Client] -->|HTTPS| B[API Gateway]
B --> C[Auth Service]
B --> D[App Server]
D --> E[(PostgreSQL)]
D --> F[(Redis Cache)]
sequenceDiagram
participant U as User
participant A as API
participant DB as Database
U->>A: POST /login
A->>DB: Validate credentials
DB-->>A: User record
A-->>U: JWT token
graph LR for left-to-right flow, graph TD for top-down-t dark -b transparent-s 2 or -s 3 for sharp images on retina displayspty: false when calling mmdcFor custom colors, create a config JSON:
{
"theme": "base",
"themeVariables": {
"primaryColor": "#f59e0b",
"primaryTextColor": "#1a1a1a",
"primaryBorderColor": "#d97706",
"lineColor": "#6b7280",
"secondaryColor": "#10b981",
"tertiaryColor": "#3b82f6"
}
}
Then: mmdc -i input.mmd -o output.png -c config.json
共 1 个版本