1 | # mermaid.cli
|
2 |
|
3 | Command-line interface for [mermaid](https://mermaidjs.github.io/).
|
4 |
|
5 | This CLI tool takes a mermaid definition file as input and generates svg/png/pdf file as output.
|
6 |
|
7 |
|
8 | ## Install locally
|
9 |
|
10 | Some people are [having issue](https://github.com/mermaidjs/mermaid.cli/issues/15) installing this tool globally. Installing it locally is an alternative solution:
|
11 |
|
12 | ```
|
13 | yarn add mermaid.cli
|
14 | ./node_modules/.bin/mmdc -h
|
15 | ```
|
16 |
|
17 | Or use NPM:
|
18 |
|
19 | ```
|
20 | npm install mermaid.cli
|
21 | ./node_modules/.bin/mmdc -h
|
22 | ```
|
23 |
|
24 |
|
25 | ## Install globally
|
26 |
|
27 | ❗️ We do **NOT** recommend installing it globally because both YARN and NPM could fail to install a command line tool globally properly due to weird permission issues.
|
28 |
|
29 | ```
|
30 | yarn global add mermaid.cli
|
31 | ```
|
32 |
|
33 | Or
|
34 |
|
35 | ```
|
36 | npm install -g mermaid.cli
|
37 | ```
|
38 |
|
39 |
|
40 | ## Examples
|
41 |
|
42 | ```
|
43 | mmdc -i input.mmd -o output.svg
|
44 | ```
|
45 |
|
46 | ```
|
47 | mmdc -i input.mmd -o output.png
|
48 | ```
|
49 |
|
50 | ```
|
51 | mmdc -i input.mmd -o output.pdf
|
52 | ```
|
53 |
|
54 | ```
|
55 | mmdc -i input.mmd -o output.svg -w 1024 -H 768
|
56 | ```
|
57 |
|
58 | ```
|
59 | mmdc -i input.mmd -t forest
|
60 | ```
|
61 |
|
62 | ```
|
63 | mmdc -i input.mmd -o output.png -b '#FFF000'
|
64 | ```
|
65 |
|
66 | ```
|
67 | mmdc -i input.mmd -o output.png -b transparent
|
68 | ```
|
69 |
|
70 |
|
71 | ## Options
|
72 |
|
73 | Please run the following command to see the latest options:
|
74 |
|
75 | ```
|
76 | mmdc -h
|
77 | ```
|
78 |
|
79 | The following is for your quick reference (may not be the latest version):
|
80 |
|
81 | ```
|
82 | Usage: mmdc [options]
|
83 |
|
84 |
|
85 | Options:
|
86 |
|
87 | -V, --version output the version number
|
88 | -t, --theme [theme] Theme of the chart, could be default, forest, dark or neutral. Optional. Default: default (default: default)
|
89 | -w, --width [width] Width of the page. Optional. Default: 800 (default: 800)
|
90 | -H, --height [height] Height of the page. Optional. Default: 600 (default: 600)
|
91 | -i, --input <input> Input mermaid file. Required.
|
92 | -o, --output [output] Output file. It should be either svg, png or pdf. Optional. Default: input + ".svg"
|
93 | -b, --backgroundColor [backgroundColor] Background color. Example: transparent, red, '#F0F0F0'. Optional. Default: white
|
94 | -c, --configFile [configFile] JSON configuration file for mermaid. Optional
|
95 | -C, --cssFile [cssFile] CSS file for the page. Optional
|
96 | -p --puppeteerConfigFile [puppeteerConfigFile] JSON configuration file for puppeteer. Optional
|
97 | -h, --help output usage information
|
98 | ```
|
99 |
|
100 |
|
101 | ## For contributors
|
102 |
|
103 | ### Setup
|
104 |
|
105 | yarn install
|
106 | cp ./node_modules/mermaid/dist/mermaid.min.js .
|
107 |
|
108 |
|
109 | ### Test
|
110 |
|
111 | Use the fixtures in `test/` to do manual testing after you change something.
|