Skip to main content

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

Project description

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)

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

md_mermaid-0.1.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

md_mermaid-0.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file md_mermaid-0.1.1.tar.gz.

File metadata

  • Download URL: md_mermaid-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for md_mermaid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71e68a658166c7e97abaa418720734d49ef2a1ff4963f3c348f14121e632ed70
MD5 75eeadbc851bbba74ce6bc0c9c09894d
BLAKE2b-256 8c1da160a3ab3af132753c704a92c7053f26eec78105773a0364f2d60a9b5c2d

See more details on using hashes here.

File details

Details for the file md_mermaid-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: md_mermaid-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for md_mermaid-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23da1dd476dd399c83247aead84af5e67b672e0fd3cb96899303ea6a8ed7717d
MD5 5ab38471c3741fd73b177a13c261f10c
BLAKE2b-256 ed852136d104d685ecfbec88ddae282fb92f4a7e9e35f47eec7ec0b3a9f4060d

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