A MkDocs plugin for including mermaid graphs in markdown sources
Project description
Mkdocs-Mermaid2
An MkDocs plugin that renders Mermaid text descriptions into diagrams (flow charts, sequence diagrams, pie charts, etc.).
- See the mkdocs-mermaid2 documentation on Read The Docs.
- See the package on Pypi.
- View the general Mkdocs documentation
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_mermaid2_plugin-1.2.1.tar.gz
.
File metadata
- Download URL: mkdocs_mermaid2_plugin-1.2.1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c7694c73a65905ac1578f966e5c193325c4d5a5bc1836727e74ac9f99d0e921 |
|
MD5 | f71a9477c9e429151710215d5c92621c |
|
BLAKE2b-256 | 3e1af580733da1924ebc9b4bb04a34ca63ae62a50b0e62eeb016e78d9dee6d69 |
File details
Details for the file mkdocs_mermaid2_plugin-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_mermaid2_plugin-1.2.1-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22d2cf2c6867d4959a5e0903da2dde78d74581fc0b107b791bc4c7ceb9ce9741 |
|
MD5 | 6efb527fac58dd9ab170e49b469ac546 |
|
BLAKE2b-256 | 24cec8a41cb0f3044990c8afbdc20c853845a9e940995d4e0cffecafbb5e927b |