Coder Social home page Coder Social logo

ob-mermaid's People

Contributors

arnm avatar flinner avatar itzikbraun avatar rudi avatar trisk3lion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ob-mermaid's Issues

allow specifying mermaid.cli arguments from org-babel headers

  • allow for specifying mmdc CLI options from org-babel syntax
  • allow for default CLI option values
❯ 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

Error in mermaid syntax hangs emacs during export

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)

:cmdline missing

I tried to use the cmdline header argument in babel, but it is missing (I wanted to use the option -f, --pdfFit).

Org-mermaid-path not recognized

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

Use mmdc's ability to read from STDIN

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")

No org-babel-execute function for mermaid!

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!

screenshot

Remarks of every window displayed in screenshot above

  1. I've added the mermaid path
  2. The diagram itself
  3. Help saying the mermaid package is installed

Can you point me to a certain direction in order to solve that issue?

is this maintained?

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).

Output into org-file

Is it possible to get the mermaid diagram to output embedded into the orgfile itself?

how to convert chinese?

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.

Option to use online service instead of a local cli tool

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.

  1. Install mermaid cli into an emacs docker image, which in its turn depends on NodeJS and so on... Image bloats and goes against docker philosophy, which suggests a separate container per component.
  2. Use an external mermaid service, either as a separate docker container or publicly available https://mermaid.ink/. This may, however, be against emacs/org/org-babel philosophy, if there is any about this matter, I'm not sure, hence I'm offering an open discussion.

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

Example in readme is incomplete

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.