pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
600 stars 165 forks source link

support for mermaidjs [enhancement] v2 #248

Closed garfvl closed 1 year ago

garfvl commented 1 year ago

Mermaid

EDIT: this PR is based on #181 and adds a couple of fixes to be able to use mermaid-cli inside a container (and fix the docker tests).

To use Mermaid, you must install mermaid-cli itself. See the mermaid-cli website for more details.

This filter assumes that the mmdc command is located in the path and therefore can be used from any location. Alternatively, you can set the environment variable MERMAID or use the pandoc's meta variable mermaid_path.

Additionally, if you need to add additional parameters to the mermaid-cli command, you can use the MERMAID_OPTIONS environment variable.

Example usage from the Mermaid page:

sequenceDiagram
Alice->>John: Hello John, how are you?
loop Healthcheck
    John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
tarleb commented 1 year ago

Just commenting to let you know that I've got this PR on my todo list; I didn't have time for a review yet.

garfvl commented 1 year ago

Just commenting to let you know that I've got this PR on my todo list; I didn't have time for a review yet.

No problem, thanks for the notification.

tarleb commented 1 year ago

The diagram generator is now maintained at https://github.com/pandoc-ext/diagram; I've added Mermaid support there.

Thank you for the contribution!