Open nickbp opened 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 ?
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.
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
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:
Some explanation of the
docker run
arguments:-u 1000
ensures that the resulting output png file has a matching UID to the current user, avoiding permissions issues when deleting or overwriting the png. The 1000 is my UID on my machine. There might be a way to figure out the UID directly in emacs.-v /tmp:/tmp
mounts the host/tmp
to/tmp
inside the container. This ensures that mmdc inside the container will be reading/writing to the host/tmp
when rendering.9.1.6
: Latest stable version as of this writing. Can check available tags here