Skip to main content

Fork of original md_mermaid by Olivier Ruelle, including some fixes with PR awaiting on the upstream

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-ort

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)

Development

Build and publish a new version on pypi

  • Increment the version in setup.py
  • Build the package:
python3 setup.py sdist bdist_wheel
  • Upload the packages on pypi:
python3 -m twine upload --repository pypi dist/*
  • Commit, tag the commit with the version number, and push all that

For the twine upload to work, it needs a ~/.pypirc file declaring the pypi repository:

[pypi]                                                                                                                                                                                                                                        
  username = __token__
  password = pypi-<AN_ALLOWED_PYPI_TOKEN>

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-ort-0.1.5.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

md_mermaid_ort-0.1.5-py3-none-any.whl (15.7 kB view hashes)

Uploaded Python 3

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