Skip to main content

markdown-d2

markdown-d2 turns D2 diagrams into pictures in a site built with zensical or Python-Markdown. You write a diagram as text in a d2 code block, and the build draws it, once for the light theme and once for the dark one. A diagram with several steps gets buttons to move through them, with a fade or a morph between steps, and any diagram can be opened full screen.

Everything happens when the site is built, so your readers download no extra software. A broken diagram stops the build with a message naming the page, the diagram and the line, instead of showing a broken picture.

Installation

uv add markdown-d2

The package brings its own Node through nodejs-wheel-binaries, so nothing else needs installing.

Use with zensical

Add the fence to zensical.toml:

[project.markdown_extensions.pymdownx.superfences]
custom_fences = [
  { name = "d2", class = "d2", format = { object = "markdown_d2.formatter", kwds = { root = "docs" } }, validator = "markdown_d2.validator" },
]

Then write a diagram in any page:

```d2
you -> page: write
page -> site: build
```

The documentation starts with a tutorial, then shows how to step through diagrams, import files and icons, change the look and use markdown-d2 without zensical, and lists every setting.

Developing

uv sync
uv run tox                # lint, types, tests, docs
uv run tox -e browser     # the figure in a real browser, with screenshots

The build copies D2 into the package, so after a change to package-lock.json run uv sync --reinstall-package markdown-d2 before testing; until then the tests still use the old copy.

D2

The wheel contains the WebAssembly build of D2 from the @d2lang/d2 package. Its source is at https://github.com/d2lang/d2 under the MPL-2.0, and its licence and notices are installed with the package in markdown_d2/node_modules/@d2lang/d2/.

Metadata

Release files for markdown-d2 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-d2 0.2.0
File Size Uploaded
markdown_d2-0.2.0.tar.gz 121.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markdown-d2 0.2.0
File Interpreter ABI Platform
markdown_d2-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 MB

Release files / markdown_d2-0.2.0.tar.gz

Download URL markdown_d2-0.2.0.tar.gz
Size 121.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2897e4e1b18c607ef0f6fec10e092467739ff810ce6b6a64b3aed5129e4a23c0
BLAKE2b-256 checksum
How to use checksums
0eacd580fbefabbdae39c319f834c329a378a52a1a4ecb6914af6852c17b2faf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / markdown_d2-0.2.0-py3-none-any.whl

Download URL markdown_d2-0.2.0-py3-none-any.whl
Size 11.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
67915ee42251feeaed3d79840dba6d1e30f3facef2421b74e5a51350294db347
BLAKE2b-256 checksum
How to use checksums
3a5ec39321ef461fdd88847320aa13177b4c0eda34d88dbccb4659ce96ea967d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page