abrochard / mermaid-mode

Emacs major mode for working with mermaid graphs https://mermaidjs.github.io/
GNU General Public License v3.0
186 stars 22 forks source link

FYI: Configuration for running mmdc via mermaid-cli docker image #27

Open nickbp opened 2 years ago

nickbp commented 2 years ago

The following configuration will allow rendering mermaid charts without needing to install nodejs+mermaid-cli to the local OS. Instead it will execute mmdc via the mermaid-cli docker image. Figured it'd make sense to note this somewhere in case someone else found it useful:

(setq mermaid-mmdc-location "docker")
(setq mermaid-flags "run -u 1000 -v /tmp:/tmp ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:9.1.6")

Some explanation of the docker run arguments:

abrochard commented 2 years ago

Thank you for sharing! I will add this to the readme.

Which docker image do you use? https://hub.docker.com/r/matthewfeickert/mermaid-cli ?

nickbp commented 2 years ago

I've been using the "official" one on the GitHub container registry, ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:9.1.6 in the above example.

nickbp commented 2 years ago

One catch I've just found is that the "current buffer" command works but the "current file" command doesn't work. I assume because the current file isn't necessarily visible to the docker container. The workaround would be to stick to the "current buffer" command where it writes the input to /tmp/current-buffer.mmd