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.3.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_mermaid2_plugin-1.2.3.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for mkdocs_mermaid2_plugin-1.2.3.tar.gz
Algorithm Hash digest
SHA256 fb6f901d53e5191e93db78f93f219cad926ccc4d51e176271ca5161b6cc5368c
MD5 ee0300c623f5eb521c9af9b6e7455c1e
BLAKE2b-256 2a6d308f443a558b6a97ce55782658174c0d07c414405cfc0a44d36ad37e36f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mkdocs_mermaid2_plugin-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 33f60c582be623ed53829a96e19284fc7f1b74a1dbae78d4d2e47fe00c3e190d
MD5 bdb14067390ff2e1630d5e7aab366c18
BLAKE2b-256 1a4b6fd6dd632019b7f522f1b1f794ab6115cd79890330986614be56fd18f0eb

See more details on using hashes here.

Supported by

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