Skip to main content

md_mermaid

mermaid extension for Python-Markdown to add support for mermaid graph inside markdown file

Installation

For pip installation (only python version >=3.x) :

pip install markdown
pip install md-mermaid

Usage

In your python script :

import markdown

text = """
# Title

Some text.

​~~~mermaid
graph TB
A --> B
B --> C
​~~~

Some other text.

​~~~mermaid
graph TB
D --> E
E --> F
​~~~
"""

html = markdown.markdown(text, extensions=['md_mermaid'])

print(html)

Output will result in :

<h1>Title</h1>
<p>Some text.</p>
<div class="mermaid">
graph TB
A --> B
B --> C
</div>

<p>Some other text.</p>
<div class="mermaid">
graph TB
D --> E
E --> F
</div>

<script>mermaid.initialize({startOnLoad:true});</script>

The <script>...</script> line appears only once even if there are several graphs in the file.

Note that the extension name have a '_' not a '-'.

Attention : don't forget to include in your output html project the two following mermaid files :

  • mermaid.css (optional, can be customised)
  • mermaid.min.js (can be download here here)

Release files for md-mermaid 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for md-mermaid 0.1.1
File Size Uploaded
md_mermaid-0.1.1.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for md-mermaid 0.1.1
File Interpreter ABI Platform
md_mermaid-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / md_mermaid-0.1.1.tar.gz

Download URL md_mermaid-0.1.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
71e68a658166c7e97abaa418720734d49ef2a1ff4963f3c348f14121e632ed70
BLAKE2b-256 checksum
How to use checksums
8c1da160a3ab3af132753c704a92c7053f26eec78105773a0364f2d60a9b5c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / md_mermaid-0.1.1-py3-none-any.whl

Download URL md_mermaid-0.1.1-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23da1dd476dd399c83247aead84af5e67b672e0fd3cb96899303ea6a8ed7717d
BLAKE2b-256 checksum
How to use checksums
ed852136d104d685ecfbec88ddae282fb92f4a7e9e35f47eec7ec0b3a9f4060d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page