Registry / web-framework / markdown-graphviz-inline

markdown-graphviz-inline

JSON →
library1.1.3pypypi✓ verified 24d ago

markdown-graphviz-inline is a Python-Markdown extension that enables rendering Graphviz DOT language diagrams directly within Markdown documents. It automatically detects ````graphviz ... ```` code blocks and replaces them with inline SVG images. This library is a Python 3 fork and continuation of the original `markdown-inline-graphviz` by Cesare Morel, currently maintained under the Backstage organization. Its current version is 1.1.3, with updates occurring on an as-needed basis.

pip install markdown-graphviz-inline
INSTALL
IMPORT
SIG · MARKDOWN-GRAPHVIZ-
M
markdown-graphviz-inline
web-frameworkpythonv1.1.3
Install
1.7s avg
Import
149ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.150s · 18.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.148s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InlineGraphvizExtension
from markdown_inline_graphviz import InlineGraphvizExtension
import markdown
makeExtension
from markdown_inline_graphviz import makeExtension
import markdown

Demonstrates how to parse Markdown text containing ````graphviz ... ```` blocks using the `markdown_inline_graphviz` extension and print the resulting HTML. This requires the Graphviz 'dot' executable to be installed on your system.

import markdown # Ensure Graphviz 'dot' executable is installed on your system and in PATH. # For example, on Ubuntu: sudo apt-get install graphviz # On macOS: brew install graphviz markdown_text = ''' # My Graph Report Here's a simple directed graph: ```graphviz digraph G { A -> B; B -> C; C -> A; } ``` And a more complex one with different shapes: ```graphviz digraph hierarchy { node [shape=box]; subgraph cluster_0 { label = "Parent Process"; a0 [label="Task 1"]; a1 [label="Task 2"]; a2 [label="Task 3"]; } subgraph cluster_1 { label = "Child Process"; b0 [label="Subtask 1"]; b1 [label="Subtask 2"]; } a0 -> a1 -> a2; a2 -> b0; b0 -> b1; } ``` ''' html_output = markdown.markdown( markdown_text, extensions=['markdown_inline_graphviz'] ) print(html_output)
Debug
Known issues
gotchaThe underlying `graphviz` Python package (a dependency) requires the Graphviz `dot` executable to be installed on your system and available in the system's PATH. Without it, the extension will fail to render graphs, potentially with errors from the `graphviz` library.
fix
Install Graphviz via your system's package manager (e.g., `sudo apt-get install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS, or download from graphviz.org) and ensure its executables are in your system's PATH.
affects: All versions
gotchaThe correct extension string to use with `markdown.markdown()` is `'markdown_inline_graphviz'`. Incorrect spelling or capitalization (e.g., `markdown_graphviz_inline`) will prevent the extension from loading and processing graph blocks.
fix
Ensure `extensions=['markdown_inline_graphviz']` is used exactly as shown in your `markdown.markdown` call.
affects: All versions
gotchaThis `markdown-graphviz-inline` library is a fork of the original `markdown-inline-graphviz` (by Cesare Morel) providing Python 3 compatibility and continued maintenance. While core functionality remains similar, users migrating from the older library should be aware of potential subtle behavioral differences.
fix
Verify behavior with existing markdown files and ensure Python 3 compatibility if migrating from the original `markdown-inline-graphviz`.
affects: Users migrating from `markdown-inline-graphviz`
Upgrade
Version history
1.1.3latest on PyPI · released Jan 27, 2025
Audit
Dependencies
MarkdownrequiredRequired for parsing Markdown and providing the extension mechanism.
graphvizrequiredRequired for generating graph images from DOT language and finding the Graphviz 'dot' executable.
Agent activity
3 hits · last 30 days
node
2
Resources
markdown-graphviz-inline — pip install markdown-graphviz-inline · libregistry