Skip to main content

A MkDocs plugin for including mermaid graphs in markdown sources

Project description

Mkdocs-Mermaid2

License: MIT PyPI Github Downloads(PyPI)

An MkDocs plugin that renders Mermaid text descriptions into diagrams (flow charts, sequence diagrams, pie charts, etc.).


As of version 1.0.0, this plugin works with versions of the Mermaid library > 10, and with lower versions.

Introduction

Mermaid2 allows you to insert mermaid markup in the markdown of your mkdocs pages.

For example, a markdown page containing the following diagram:

```mermaid
graph LR
    hello --> world
    world --> again
    again --> hello
```

will then be displayed in the final HTML page as:

graph LR
    hello --> world
    world --> again
    again --> hello

The diagram will be rendered on the fly by the web browser, with the use of the mermaid javascript library. mkdocs-mermaid2 takes care of inserting the javascript library into the html page.

You can use all the diagrams types supported by the version of the Mermaid javascript library that you are using (flowchart, class, state, timeline, etc.).

Installation

Automatic

pip install mkdocs-mermaid2-plugin

Manual

Clone this repository in a local directory and install the package:

python setup.py install

Test

For running the examples the test directory, you will also need the mkdocs-material theme. You may install it directly, or use the following command to install the whole package:

pip install mkdocs-mermaid2-plugin[test]

Configuration

Basic configuration

To enable this plugin, you need to declare it in your mkdocs config file (mkdocs.yml).

In order to work, the plugin also requires the mermaid javascript library (in the example below, it fetched from the last version from the unpkg repository; change the version no as needed).

plugins:
    - search
    - mermaid2

Note: If you declare plugins, you need to declare all of them, including search (which would otherwise have been installed by default.)

Specifying the version of the Mermaid library

By default, the plugin selects a version of the Mermaid javascript library that is known to work (some versions work better than others).

You may specify a different version of the Mermaid library, like so:

plugins:
  - search
  - mermaid2:
      version: 10.0.2

The plugin will insert the correct call to the javascript library inside the final HTML page.

Additional settings for the Material theme

The Material theme, developed by squidfunk is not mandatory, but recommended.

Mermaid diagrams will automatically adapt their colors to the theme and palette.

Here are the additional recommended settings in the configuration file:

markdown_extensions:
  - pymdownx.superfences:
        # make exceptions to highlighting of code:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:mermaid2.fence_mermaid_custom

Do not use these additional settings for other themes, as diagrams will probably not be displayed correctly.

For more information

See the documentation on ReadTheDocs.

Project details


Download files

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

Source Distribution

mkdocs_mermaid2_plugin-1.2.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

mkdocs_mermaid2_plugin-1.2.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_mermaid2_plugin-1.2.1.tar.gz.

File metadata

File hashes

Hashes for mkdocs_mermaid2_plugin-1.2.1.tar.gz
Algorithm Hash digest
SHA256 9c7694c73a65905ac1578f966e5c193325c4d5a5bc1836727e74ac9f99d0e921
MD5 f71a9477c9e429151710215d5c92621c
BLAKE2b-256 3e1af580733da1924ebc9b4bb04a34ca63ae62a50b0e62eeb016e78d9dee6d69

See more details on using hashes here.

File details

Details for the file mkdocs_mermaid2_plugin-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_mermaid2_plugin-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22d2cf2c6867d4959a5e0903da2dde78d74581fc0b107b791bc4c7ceb9ce9741
MD5 6efb527fac58dd9ab170e49b469ac546
BLAKE2b-256 24cec8a41cb0f3044990c8afbdc20c853845a9e940995d4e0cffecafbb5e927b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page