Linux command
mermaid 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate diagram from file
mmdc -i [input.mmd] -o [output.png]
Output as SVG
mmdc -i [input.mmd] -o [output.svg]
Output as PDF
mmdc -i [input.mmd] -o [output.pdf]
Use specific theme
mmdc -i [input.mmd] -o [output.png] -t [dark]
Set background color
mmdc -i [input.mmd] -o [output.png] -b [white]
Read from stdin
echo "graph LR; A-->B" | mmdc -o [diagram.png]
说明
mmdc (Mermaid CLI) renders Mermaid diagrams from text definitions to images. Mermaid is a diagramming language for flowcharts, sequence diagrams, class diagrams, and more. The tool enables automated diagram generation in documentation pipelines and scripts.
参数
- -i _file_
- Input mermaid file.
- -o _file_
- Output file.
- -t _theme_
- Theme (default, forest, dark, neutral).
- -b _color_
- Background color.
- -c _file_
- Config JSON file.
- -w _width_
- Width in pixels.
- -H _height_
- Height in pixels.
- -p _file_
- Puppeteer config file.
- -s _scale_
- Scale factor (puppeteer device pixel ratio).
- -e _format_
- Output format: _png_, _svg_, _pdf_, or _md_ (overrides extension).
- -f, --pdfFit
- Scale PDF to fit the chart on a single page.
- -q, --quiet
- Suppress informational output.
- -I / --svgId _id_
- Set the `id` attribute on the generated SVG element.
- --cssFile _path_
- Inject a custom CSS stylesheet into the SVG.
FAQ
What is the mermaid command used for?
mmdc (Mermaid CLI) renders Mermaid diagrams from text definitions to images. Mermaid is a diagramming language for flowcharts, sequence diagrams, class diagrams, and more. The tool enables automated diagram generation in documentation pipelines and scripts.
How do I run a basic mermaid example?
Run `mmdc -i [input.mmd] -o [output.png]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i _file_ do in mermaid?
Input mermaid file.