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
- pip (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
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
md_mermaid-0.1.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
md_mermaid-0.1.0-py3-none-any.whl
(15.3 kB
view hashes)
Close
Hashes for md_mermaid-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a82e52ede1c9f0add7ce476aeea1979a1c5517df97377fe858cd26c2d8645db1 |
|
MD5 | c045032b02dc32c5599706202cefaec5 |
|
BLAKE2b-256 | 55d695fc81efef27de84490a941788a3ff00b8e6a55284aa8ab0fc42623fb0b9 |