Linux command
mmdc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate an SVG diagram from a file
mmdc -i [input.mmd] -o [output.svg]
Generate a PNG with a dark theme
mmdc -i [input.mmd] -o [output.png] -t dark
Generate a PDF scaled to fit the chart
mmdc -i [input.mmd] -o [output.pdf] -f
Set custom page dimensions and scale
mmdc -i [input.mmd] -o [output.png] -w [1200] -H [800] -s [2]
Use a custom Mermaid configuration file
mmdc -i [input.mmd] -o [output.svg] -c [config.json]
Read from stdin with transparent background
cat [diagram.mmd] | mmdc -i - -o [output.svg] -b transparent
Process a Markdown file
mmdc -i [document.md] -o [document-out.md]
说明
mmdc is the CLI for the Mermaid diagramming library. It renders diagrams defined in Mermaid's text-based syntax into SVG, PNG, or PDF output using a headless Chromium browser via Puppeteer. Supported diagram types include flowcharts, sequence diagrams, class diagrams, state diagrams, Gantt charts, pie charts, ER diagrams, and more. When given a Markdown file as input, mmdc extracts and renders embedded Mermaid code blocks, replacing them with generated images. The --configFile option accepts a JSON file that configures Mermaid behavior and is merged with the --theme option, with the config file taking precedence.
参数
- -i, --input _FILE_
- Input file path. Use `-` for stdin. Files ending in .md or .markdown are treated as Markdown.
- -o, --output _FILE_
- Output file path. Use `-` for stdout. Defaults to `{input}.svg`.
- -e, --outputFormat _FORMAT_
- Output format: svg, png, or pdf. Inferred from output extension by default.
- -t, --theme _THEME_
- Mermaid theme: default, dark, forest, or neutral.
- -b, --backgroundColor _COLOR_
- Background color for PNG/SVG output (default: white).
- -w, --width _WIDTH_
- Page width in pixels (default: 800).
- -H, --height _HEIGHT_
- Page height in pixels (default: 600).
- -s, --scale _FACTOR_
- Puppeteer scale factor for deviceScaleFactor (default: 1).
- -f, --pdfFit
- Scale PDF output to fit chart dimensions.
- -c, --configFile _FILE_
- JSON configuration file for Mermaid settings.
- -C, --cssFile _FILE_
- Path to custom CSS file for injection into the page.
- -I, --svgId _ID_
- ID attribute for the SVG element (default: my-svg).
- -p, --puppeteerConfigFile _FILE_
- JSON configuration file for Puppeteer launch options.
- -a, --artefacts _PATH_
- Output path for images when processing Markdown files.
- -q, --quiet
- Suppress log output to stdout.
- -V, --version
- Display version number.
- -h, --help
- Display help information.
FAQ
What is the mmdc command used for?
mmdc is the CLI for the Mermaid diagramming library. It renders diagrams defined in Mermaid's text-based syntax into SVG, PNG, or PDF output using a headless Chromium browser via Puppeteer. Supported diagram types include flowcharts, sequence diagrams, class diagrams, state diagrams, Gantt charts, pie charts, ER diagrams, and more. When given a Markdown file as input, mmdc extracts and renders embedded Mermaid code blocks, replacing them with generated images. The --configFile option accepts a JSON file that configures Mermaid behavior and is merged with the --theme option, with the config file taking precedence.
How do I run a basic mmdc example?
Run `mmdc -i [input.mmd] -o [output.svg]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i, --input _FILE_ do in mmdc?
Input file path. Use `-` for stdin. Files ending in .md or .markdown are treated as Markdown.