Skip to main content

Python-Markdown extension to add Mermaid graph

Project description

PRs Welcome Conventional Commits Github Actions PyPI Package latest release PyPI Package download count (per month) Supported versions

markdown-mermaidjs

Python-Markdown extension to add Mermaid graph

Getting Started

Prerequisites

Installation

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

pip install markdown-mermaidjs

Usage

With 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=["markdown-mermaidjs"])

print(html)

Expected output

<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 type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
    mermaid.initialize({ startOnLoad: true });
</script>

Use it with Pelican

Add "markdown_mermaidjs": {} to MARKDOWN["extension_configs"] in your pelicanconf.py

MARKDOWN = {
    "extension_configs": {
        "markdown_mermaidjs": {},
    },
}

Contributing

See Contributing

Authors

Wei Lee weilee.rx@gmail.com

This is a forked project of oruelle/md_mermaid

Created from Lee-W/cookiecutter-python-template version 1.10.1

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

markdown_mermaidjs-1.0.0.tar.gz (84.3 kB view hashes)

Uploaded Source

Built Distribution

markdown_mermaidjs-1.0.0-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