Name | markdown-mermaid-cli JSON |
Version |
0.2.3
JSON |
| download |
home_page | None |
Summary | Mermaid extension for Python-Markdown using mermaid-cli. |
upload_time | 2025-10-07 03:42:23 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
markdown
mermaid
mkdocs
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# [markdown-mermaid-cli](https://hkato.github.io/markdown-mermaid-cli/)
[](https://pypi.org/project/markdown-mermaid-cli/)


[Mermaid][mermaid] extension for [Python-Markdown][python-markdown] using [Mermaid-CLI][mermaid-cli].
This extension converts Mermaid diagram code blocks into Base64 encoded [data: URI][data-uri].
This enables PDF generation with tools like [MkDocs to PDF][mkdocs-to-pdf]/[WeasyPrint][wasyprint]
without requiring client-side JavaScript.
## Install
```sh
pip install markdown-mermaid-cli
```
## Requirements
### Mermaid CLI
> Chrome or Chromium is required to run Mermaid-CLI.
```sh
npm install @mermaid-js/mermaid-cli
```
or
```sh
npm install --global @mermaid-js/mermaid-cli
```
## Usage
- code block start with <code>```mermaid</code>
- code block end with <code>```</code>
options:
```markdown
formant=[svg|png] {img attribute}="value" {cli option}="value"`
```
- format (optional): Output image format (defaults to svg)
- img attribute (optional): alt, width, height, class, id, style, title
- cli option (optional): theme, width, height, backgroundColor, svgId, scale (refer to `mmdc -h`)
### [MkDocs][mkdocs] Integration
```yaml
# mkdocs.yml
markdown_extensions:
- markdown_mermaid_cli
```
### [Pelican][pelican] Integration
```py
# pelicanconf.py
MARKDOWN = {
'extension_configs': {
'markdown.extensions.codehilite': {'css_class': 'highlight'},
'markdown.extensions.extra': {},
'markdown_mermaid_cli': {}, # Add this
},
'output_format': 'html5',
}
```
### Python code
````python
import markdown
from markdown_mermaid_cli import MermaidExtension
markdown_text = """```mermaid
sequenceDiagram
participant Alice
participant Bob
Bob->>Alice: Hi Alice
Alice->>Bob: Hi Bob
```"""
html_output = markdown.markdown(
markdown_text, extensions=[MermaidExtension()]
)
print(html_output)
````
```html
<p><img src="data:image/svg+xml;base64,PHN2ZyBhcmlhLXJvbGVkZXNjcmlwdGlvbj0ic2VxdWVuY2UiIHJvbGU
9ImdyYXBoaWNzLWRvY3VtZW50IGRvY3VtZW50IiB2aWV3Qm94PSItNTAgLTEwIDc1MCA1NzQiIHN0eWxlPSJtYXgtd2lkd
Gg6IDc1MHB4OyBiYWNrZ3JvdW5kLWNvbG9yOiB3aGl0ZTsiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk
...
...
...
IHgxPSIyNzYiLz48L3N2Zz4=" ></p>
```
## Process flow
```mermaid
sequenceDiagram
participant application as Application<br/>(eg MkDocs)
participant markdown as Python Markdown
participant extension as MermaidDataURIExtension
participant engine as Mermaid CLI
application->>markdown: Markdown + Mermaid
markdown->>extension: Preprocessor
extension->>engine: Mermaid
engine-->>engine: Convert
engine-->>extension: Image Data
extension-->>extension: Base64 encode
extension-->>markdown: Markdown + data URI image
markdown-->>application: HTML + data URI image
```
[mermaid]: https://mermaid.js.org/
[python-markdown]: https://python-markdown.github.io/
[mermaid-cli]: https://github.com/mermaid-js/mermaid-cli
[data-uri]: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data
[mkdocs-to-pdf]: https://mkdocs-to-pdf.readthedocs.io/
[wasyprint]: https://weasyprint.org/
[mkdocs]: https://www.mkdocs.org/
[pelican]: https://getpelican.com/
Raw data
{
"_id": null,
"home_page": null,
"name": "markdown-mermaid-cli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "markdown, mermaid, mkdocs",
"author": null,
"author_email": "Hideyuki KATO <hideyuki@kato.jp>",
"download_url": "https://files.pythonhosted.org/packages/27/1c/5b7090786bda1b6349028fb80aa203d5a1b6e8f39cde789dcc59d8f05523/markdown_mermaid_cli-0.2.3.tar.gz",
"platform": null,
"description": "# [markdown-mermaid-cli](https://hkato.github.io/markdown-mermaid-cli/)\n\n[](https://pypi.org/project/markdown-mermaid-cli/)\n\n\n\n[Mermaid][mermaid] extension for [Python-Markdown][python-markdown] using [Mermaid-CLI][mermaid-cli].\n\nThis extension converts Mermaid diagram code blocks into Base64 encoded [data: URI][data-uri].\nThis enables PDF generation with tools like [MkDocs to PDF][mkdocs-to-pdf]/[WeasyPrint][wasyprint]\nwithout requiring client-side JavaScript.\n\n## Install\n\n```sh\npip install markdown-mermaid-cli\n```\n\n## Requirements\n\n### Mermaid CLI\n\n> Chrome or Chromium is required to run Mermaid-CLI.\n\n```sh\nnpm install @mermaid-js/mermaid-cli\n```\n\nor\n\n```sh\nnpm install --global @mermaid-js/mermaid-cli\n```\n\n## Usage\n\n- code block start with <code>```mermaid</code>\n- code block end with <code>```</code>\n\noptions:\n\n```markdown\nformant=[svg|png] {img attribute}=\"value\" {cli option}=\"value\"`\n```\n\n- format (optional): Output image format (defaults to svg)\n- img attribute (optional): alt, width, height, class, id, style, title\n- cli option (optional): theme, width, height, backgroundColor, svgId, scale (refer to `mmdc -h`)\n\n### [MkDocs][mkdocs] Integration\n\n```yaml\n# mkdocs.yml\nmarkdown_extensions:\n - markdown_mermaid_cli\n```\n\n### [Pelican][pelican] Integration\n\n```py\n# pelicanconf.py\nMARKDOWN = {\n 'extension_configs': {\n 'markdown.extensions.codehilite': {'css_class': 'highlight'},\n 'markdown.extensions.extra': {},\n 'markdown_mermaid_cli': {}, # Add this\n },\n 'output_format': 'html5',\n}\n```\n\n### Python code\n\n````python\nimport markdown\nfrom markdown_mermaid_cli import MermaidExtension\n\nmarkdown_text = \"\"\"```mermaid\nsequenceDiagram\n participant Alice\n participant Bob\n Bob->>Alice: Hi Alice\n Alice->>Bob: Hi Bob\n```\"\"\"\n\nhtml_output = markdown.markdown(\n markdown_text, extensions=[MermaidExtension()]\n)\n\nprint(html_output)\n````\n\n```html\n<p><img src=\"data:image/svg+xml;base64,PHN2ZyBhcmlhLXJvbGVkZXNjcmlwdGlvbj0ic2VxdWVuY2UiIHJvbGU\n9ImdyYXBoaWNzLWRvY3VtZW50IGRvY3VtZW50IiB2aWV3Qm94PSItNTAgLTEwIDc1MCA1NzQiIHN0eWxlPSJtYXgtd2lkd\nGg6IDc1MHB4OyBiYWNrZ3JvdW5kLWNvbG9yOiB3aGl0ZTsiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk\n...\n...\n...\nIHgxPSIyNzYiLz48L3N2Zz4=\" ></p>\n```\n\n## Process flow\n\n```mermaid\nsequenceDiagram\n participant application as Application<br/>(eg MkDocs)\n participant markdown as Python Markdown\n participant extension as MermaidDataURIExtension\n participant engine as Mermaid CLI\n\n application->>markdown: Markdown + Mermaid\n markdown->>extension: Preprocessor\n extension->>engine: Mermaid\n engine-->>engine: Convert\n engine-->>extension: Image Data\n extension-->>extension: Base64 encode\n extension-->>markdown: Markdown + data URI image\n markdown-->>application: HTML + data URI image\n```\n\n[mermaid]: https://mermaid.js.org/\n[python-markdown]: https://python-markdown.github.io/\n[mermaid-cli]: https://github.com/mermaid-js/mermaid-cli\n[data-uri]: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data\n[mkdocs-to-pdf]: https://mkdocs-to-pdf.readthedocs.io/\n[wasyprint]: https://weasyprint.org/\n[mkdocs]: https://www.mkdocs.org/\n[pelican]: https://getpelican.com/\n",
"bugtrack_url": null,
"license": null,
"summary": "Mermaid extension for Python-Markdown using mermaid-cli.",
"version": "0.2.3",
"project_urls": {
"Changelog": "https://github.com/hkato/markdown-mermaid-cli/blob/main/CHANGELOG.md",
"Documentation": "https://hkato.github.io/markdown-mermaid-cli/",
"Homepage": "https://github.com/hkato/markdown-mermaid-cli",
"Issues": "https://github.com/hkato/markdown-mermaid-cli/issues",
"Repository": "https://github.com/hkato/markdown-mermaid-cli"
},
"split_keywords": [
"markdown",
" mermaid",
" mkdocs"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c4983e3e3d2a696511f6b6a4cad3d876ec5e883fd2bc520361af4f9a79275783",
"md5": "107606d4473d1933d597dec9ead036e7",
"sha256": "72446f4968db0ba1c7378b7b943a383b1f64edbdd4b594b7f28b7d7aef3cdaa8"
},
"downloads": -1,
"filename": "markdown_mermaid_cli-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "107606d4473d1933d597dec9ead036e7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6271,
"upload_time": "2025-10-07T03:42:21",
"upload_time_iso_8601": "2025-10-07T03:42:21.538626Z",
"url": "https://files.pythonhosted.org/packages/c4/98/3e3e3d2a696511f6b6a4cad3d876ec5e883fd2bc520361af4f9a79275783/markdown_mermaid_cli-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "271c5b7090786bda1b6349028fb80aa203d5a1b6e8f39cde789dcc59d8f05523",
"md5": "43ba5c79980a40751e64e5608ff86c5b",
"sha256": "07b12b2aebd05a96daa255e1e7ed23612a7b1bab9ec7f16f951bc770e67f2d78"
},
"downloads": -1,
"filename": "markdown_mermaid_cli-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "43ba5c79980a40751e64e5608ff86c5b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 74606,
"upload_time": "2025-10-07T03:42:23",
"upload_time_iso_8601": "2025-10-07T03:42:23.104138Z",
"url": "https://files.pythonhosted.org/packages/27/1c/5b7090786bda1b6349028fb80aa203d5a1b6e8f39cde789dcc59d8f05523/markdown_mermaid_cli-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-07 03:42:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hkato",
"github_project": "markdown-mermaid-cli",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "markdown-mermaid-cli"
}