mermaid-ascii-diagrams
Render Mermaid diagrams to terminal-friendly text (ASCII/Unicode). This tool extracts fenced ```mermaid blocks from Markdown and renders them as Unicode box-drawing diagrams.
Features
- CLI to render Mermaid code blocks from Markdown
- Supports
flowchart/graphandsequenceDiagram - Parses
classDiagramandstateDiagram/stateDiagram-v2into a generic graph renderer (limited) - No browser / no JavaScript
Installation
pip install mermaid-ascii-diagrams
Requires Python 3.10+.
Command-line usage
Render all Mermaid blocks in a Markdown file:
mermaid-ascii diagram.md
Read Markdown from stdin:
cat diagram.md | mermaid-ascii -
Write output to a file:
mermaid-ascii diagram.md -o diagram.txt
Render only the first block:
mermaid-ascii --first diagram.md
Render a specific block (0-based index):
mermaid-ascii --index 1 diagram.md
Wrap each rendered diagram in a Markdown ```text fence:
mermaid-ascii --markdown diagram.md
Notes:
- When multiple Mermaid blocks are rendered, outputs are separated by a
--------------------divider. - If no Mermaid blocks are found (or
--indexis out of range), the CLI prints an error message and exits non-zero.
Example
Input (Markdown):
```mermaid
flowchart LR
A([Start]) --> B{Valid?}
B --> C[Continue]
B --> D[Error]
C --> E([End])
D --> E
```
Output (text):
╭───────╮ ╱──────╲ ┌──────────┐
│ Start ├──────► Valid? │──► Continue ├──┐
╰───────╯ ╲──────╱ └──────────┘ │
┌─────┴───╮
│ End │
╰─────────╯
┌───────┐ ▲
│ Error │─────────────┘
└───────┘
(Exact output depends on terminal width and diagram complexity.)
Supported syntax (current)
Flowcharts (flowchart / graph):
- Directions:
TB,BT,LR,RL - Edges:
-->,---,==> - Node shapes:
A[Label]boxA{Label}diamondA([Label])rounded/terminator
- Edge labels like
A -->|yes| Bare currently ignored (the edge is still drawn).
Sequence diagrams (sequenceDiagram):
participant Nameandparticipant Name as Label- Messages with arrows:
->,->>,-->,-->>, and--(line without arrowhead) activate Name/deactivate Name+/-receiver flags on messages (activate/deactivate the receiver)
Class/state diagrams:
classDiagram,stateDiagram/stateDiagram-v2are parsed into a generic graph and rendered with the flowchart renderer.- Many Mermaid features (styling, subgraphs, notes, etc.) are ignored.
Python usage
from mermaid_ascii import parse_mermaid, render_ascii
src = """
flowchart LR
A --> B
"""
diagram = parse_mermaid(src)
print(render_ascii(diagram))
License
MIT License
Contributing
Issues and pull requests are welcome.
If you're adding new syntax support or changing layout/routing, please include before/after rendered output examples (ideally from real Mermaid snippets).
Metadata
Release files for mermaid-ascii-diagrams 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mermaid_ascii_diagrams-0.1.1.tar.gz | 14.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mermaid_ascii_diagrams-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.8 kB
Release files / mermaid_ascii_diagrams-0.1.1.tar.gz
| Download URL | mermaid_ascii_diagrams-0.1.1.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0bd8dcf3b57361a37d9c10853b3190bf7916b7c8f12cec2dd37bfaad23de485
|
|
BLAKE2b-256 checksum How to use checksums |
bb173647eeae316dcb3ec8a6b4bf8290d898e838f4274577e6e7b13a1884ce99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / mermaid_ascii_diagrams-0.1.1-py3-none-any.whl
| Download URL | mermaid_ascii_diagrams-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6098969993011fa989998ee6c7f6c8021f27ddf8f9556f6b5b82361039d2b4ad
|
|
BLAKE2b-256 checksum How to use checksums |
eae6e42a90b54763c21d2072c6f2838400d1de2f6ce85a1d728c9141f167a501
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|