arnm / ob-mermaid Goto Github PK
View Code? Open in Web Editor NEWGenerate mermaid diagrams within Emacs org-mode babel
License: GNU General Public License v3.0
Generate mermaid diagrams within Emacs org-mode babel
License: GNU General Public License v3.0
mmdc
CLI options from org-babel syntax❯ mmdc --help
Usage: mmdc [options]
Options:
-V, --version output the version number
-t, --theme [theme] Theme of the chart, could be default, forest, dark or neutral. Optional. Default: default (default: default)
-w, --width [width] Width of the page. Optional. Default: 800 (default: 800)
-H, --height [height] Height of the page. Optional. Default: 600 (default: 600)
-i, --input <input> Input mermaid file. Required.
-o, --output [output] Output file. It should be either svg, png or pdf. Optional. Default: input + ".svg"
-b, --backgroundColor [backgroundColor] Background color. Example: transparent, red, '#F0F0F0'. Optional. Default: white
-c, --configFile [configFile] JSON configuration file for mermaid. Optional
-C, --cssFile [cssFile] CSS file for the page. Optional
-p --puppeteerConfigFile [puppeteerConfigFile] JSON configuration file for puppeteer. Optional
-h, --help output usage information
Example:
Here the width
and height
CLI options would be specified as part of org-babel syntax.
#+begin_src mermaid :file test.png :width 100 :heigth 100
sequenceDiagram
A-->B: Works!
#+end_src
If I made a syntax error in my mermaid file, instead of reporting the error, the exporter hangs.
Not sure how this would be solved, since it is mostly using the babel machinery.
Will look around for a way. If you have suggestions I'd gladly try out.
OS: Windows (haven't tried if the same problem is present in Linux)
I tried to use the cmdline
header argument in babel, but it is missing (I wanted to use the option -f, --pdfFit).
Hello,
I am not a programmer so excuse me if I don't use the right words.
With your config
(setq org-mermaid-path "/your-installating-path/node_modules/.bin/mmdc")
I had the following error:
'ob-mermaid-cli-path is not set'
when evaluating the code block.
However, changing the name of the variable to
(setq ob-mermaid-cli-path "~/node_modules/.bin/mmdc")
in my dotfile worked fine.
I don't know if this solve anything, just wanted to point it out.
Cheers
As mermaid-cli
allows piping from STDIN it would be nice to bypass the creation of a temporary file in this mode.
This would make ob-mermaid
work with containerized installations without affecting current usage scenarios.
For example, with the following script at /some_path/mmdc
:
#!/usr/bin/env sh
docker run --rm -i -u `id -u`:`id -g` -v $(pwd):/data minlag/mermaid-cli:10.6.1 mmdc "$@"
I am able to generate diagrams as follows:
$ cat test.mmd | ./mmdc -o test.png
So if this behaviour was reflected in ob-mermaid.el
the following configuration would be enough to make it work with containers:
(setq ob-mermaid-cli-path "/some_path/mmdc")
It should link to:
https://github.com/mermaid-js/mermaid-cli
maybe adding also installation instructions like
yarn global add mermaid-cli
Hi Alexei @arnm
You're package is exacly what I'm looking for. Thank you so much for that.
I've encountered spacemacs a few days ago and now need help on the subjected message.
Having the diagram under the cursor and hitting C-c C-c
results in:
No org-babel-execute function for mermaid!
Can you point me to a certain direction in order to solve that issue?
Is this a stalled/suspended project, or is the plan to actively develop it? I found mermaid-mode
which is certainly different (not org-babel).
There is a small spelling mistake in puppeteer.
Within the .el file it is spelled "pupeteer" and as a result we have the wrong spelling whenever we want to append a config file.
Is it possible to get the mermaid diagram to output embedded into the orgfile itself?
I am using emacs 29.0.50 in win10, and installed mermaid and ob-mermaid.
when using mermaid in org-mode, mermaid can convert english word correct, but chinese can not show in image.
maybe i miss some configuration?
thanks.
That is a feature request to consider. Whether it is a good pratice or not, is an open discussion.
Use case: emacs runs as a service in a docker container to convert a tree of org files to a tree of html files.
And now it is a dilemma how to render mermaid source blocks.
To solve my problem, I will do my own custom ob-mermaid
which will encode the source block by first replacing line ends and tabs with \n
and \t
and so on respectively, then make JSON like {"code":"...content..."}
, then Base64 encode the JSON, and send as a web request https://mermaid.ink/svg/<encoded_content>
or https://mermaid.ink/img/<encoded_content>
, depending on which format is preferred, SVG or PNG. The question is, am I the only one who finds this functionality useful? If that all makes sense to others, the feature described might become a useful part of this module.
Thanks
The new place is apparently https://github.com/mermaid-js/mermaid-cli.
Hi,
It would be helpful if the readme had a complete example. Specifically, the #+BEGIN_SRC
headers are not shown, so the user has to guess whether to add mermaid
or something else.
0001-added-other-CLI-arguments-fixed-bug-in-using-numeric.patch
I have uploaded the fork here, but Github doesn't let me send a PR from that repo as it isn't a Github-sanctioned "fork." Github sucks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.