Org Mode + Mermaid

Published on Sep 19, 2021, by Junji Zhi

It’s neat to be able to render diagrams and flowcharts from text, which leads us to Mermaid.


Follow installation steps to install mermaid-cli.

If you are in Mac OS X, run:

brew install mermaid-cli

Then install ob-mermaid package in Emacs.

Remember to set the mermaid CLI executable path:

(setq ob-mermaid-cli-path "/usr/local/bin/mmdc")


In any org file, you can use `mermaid` source type, and specify the output file’s name:

#+begin_src mermaid :file test.png
 A-->B: Works!

Inside the code block and press Ctrl-c Ctrl-c, and you would see:


Note: I found Emacs doesn’t render *.svg files well, so for the source block I always use *.png, which renders well enough for my use.