Skip to main content

Mermaid diagrams preprocessor for Foliant.

Project description

Mermaid Diagrams Preprocessor for Foliant

Mermaid is an open source diagram visualization tool. This preprocessor converts Mermaid diagram definitions in your Markdown files into images on the fly during project build.


$ pip install foliantcontrib.mermaid

Please note that to use this preprocessor you will also need to install Mermaid and Mermaid CLI:

$ npm install mermaid # installs locally
$ npm install mermaid.cli


To enable the preprocessor, add mermaid to preprocessors section in the project config:

    - mermaid

The preprocessor has a number of options:

    - mermaid:
        cache_dir: !path .diagramscache
        mermaid_path: !path node_modules/.bin/mmdc
        format: svg

cache_dir : Path to the directory with the generated diagrams. It can be a path relative to the project root or a global one; you can use ~/ shortcut.

To save time during build, only new and modified diagrams are rendered. The generated images are cached and reused in future builds.

mermaid_path : Path to Mermaid CLI binary. If you installed Mermaid locally this parameter is required. Default: mmdc.

format : Generated image format. Available: svg, png, pdf. Default svg.

params : Params passed to the image generation command:

        - mermaid:
                theme: forest

To see the full list of available params, run mmdc -h or check here.


To insert a diagram definition in your Markdown source, enclose it between <mermaid>...</mermaid> tags:

Here’s a diagram:

graph TD;

You can set any parameters in the tag options. Tag options have priority over the config options so you can override some values for specific diagrams while having the default ones set up in the config.

Tags also have an exclusive option caption — the markdown caption of the diagram image.

Diagram with a caption:

<mermaid caption="Deployment diagram"
          params="theme: dark">

Note that command params listed in the params option are stated in YAML format. Remember that YAML is sensitive to indentation so for several params it is more suitable to use JSON-like mappings: {key1: 1, key2: 'value2'}.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for foliantcontrib.mermaid, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size foliantcontrib.mermaid-1.0.2-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size foliantcontrib.mermaid-1.0.2.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page