Pandoc filter for mermaid
Last updated 2 years ago by anderswestberg .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @anderswestberg/mermaid-filter -g
SYNC missed versions from official npm registry.

Sequence and Graph diagrams in your markdown files!

mermaid-filter is a pandoc filter that adds support for mermaid syntax diagrams in markdown.

Write your diagrams in fenced code blocks as usual like this:

    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!

and get this in rendered doc

Installation and usage

  1. npm install --global mermaid-filter
  2. To convert your markdown file something.md into something.html, use pandoc -t html -F mermaid-filter -o something.html something.md

WINDOWS - you need mermaid-filter.cmd in the line above

Windows 8.1 - On windows 8.1, mermaid-filter.cmd fails - apparently due to change in how the CMD.exe works for subprocesses? - see this issue thread. You have to edit the globally installed mermaid-filter.cmd located in c:\users\<username>\AppData\Roaming\npm to use ~dp$PATH:0. Unfortunately, you will need to do this each time you install/update mermaid-filter since it overwrites the cmd file.


You have a couple of formatting options via attributes of the fenced code block to control the rendering

  • Pandoc caption, the filename is this value cleaned up - Use {.mermaid caption="Caption Text Here"}
  • Image Format - Use {.mermaid format=svg} Default is png
  • Width - Use {.mermaid width=400} default with is 500
  • Theme - Use {.mermaid theme=forest} default is 'default'. Corresponds to --theme flag of mermaid.cli
  • Filename - Use {.mermaid filename="file with space"} to set the filename. This has priority over the caption
  • Save path - Use {.mermaid loc=img} default loc=inline which will encode the image in a data uri scheme.
    • Possible values for loc
      • loc=inline - default; encode image to data uri on img tag.
        • For widest compatibility, use png (default)
        • SVG has trouble on IE11
      • loc=imgur - upload png to imgur and link to it.
      • loc=<anythingelse> -treat as folder name to place images into

Note that to specify options, you need to use the curly braces syntax and have the .mermaid class attached. Admittedly, this is uglier than the earlier syntax on top - but that's how Pandoc wants it.

JSON and CSS configuration

Mermaid cli allows you to specify additional options in a json configuration file and a css file. mermaid-filter will look in the current working directory for .mermaid-config.json and .mermaid.css and if found, pass them in to mermaid cli.

Puppeteer Configuration - mermaid-filter will look in the current working directory for a .puppeteer.json and pass it on to mermaid cli (-p option of mmdc)if found

Current Tags

  • 1.2.1                                ...           latest (2 years ago)

1 Versions

  • 1.2.1                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (7)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |