MkDocs Mermaid2 Plugin

1.2.3 · active · verified Sat Apr 11

An MkDocs plugin (current version 1.2.3) for seamlessly embedding Mermaid.js diagrams within Markdown source files, rendering them dynamically in your generated documentation. It is actively maintained with regular updates, enabling complex diagrams like flowcharts, sequence diagrams, and gantt charts directly in your MkDocs site.

Warnings

Install

Imports

Quickstart

To enable the plugin, add 'mermaid2' to your `plugins` list in `mkdocs.yml`. If you declare any plugin, you must explicitly list all of them, including `search`. For best integration, especially with Material for MkDocs, it's recommended to also configure `pymdownx.superfences` to handle `mermaid` custom fences. Then, in your Markdown files, use a `mermaid` fenced code block to embed your diagrams.

### mkdocs.yml
plugins:
  - search
  - mermaid2
markdown_extensions:
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:mermaid2.fence_mermaid_custom

### docs/index.md
# My Project Documentation

Here's a simple flowchart:

```mermaid
graph TD
    A[Start] --> B{Process?};
    B --> C{Decision};
    C --> D[End];
```

view raw JSON →