Skip to main content

Python bindings for illusion Markdown (MDI), backed by the Rust core.

Project description

illusion-markdown

PyPI Python License

Official Python bindings for illusion Markdown (MDI). illusion-markdown parses complete MDI documents, returns the versioned document IR, and renders HTML, text, EPUB, and DOCX through the canonical Rust implementation. Python is an ergonomic API layer only: it does not carry a second Markdown parser or renderer.

Read the Python API documentation →

Install

pip install illusion-markdown

The PyPI distribution is illusion-markdown; the Python import namespace is mdi. Python 3.10 or newer is required.

Quick start

import mdi

source = """---
title: 東京の夜
lang: ja
---

# {東京|とうきょう}の夜

第^12^話
"""

result = mdi.parse(source)
print(result["document"]["children"][0]["type"])

html = mdi.render_html(source)
open("book.html", "w", encoding="utf-8").write(html)

parse() returns a JSON-compatible dictionary with the MDI syntax version, IR version, parser capabilities, document tree, and recoverable diagnostics. Every source-backed span is a half-open UTF-8 byte range.

API

Function Result
mdi.parse(source) Versioned document IR and diagnostics.
mdi.serialize_mdi(source) Canonical MDI/Markdown source.
mdi.render_html(source) A standalone HTML document.
mdi.render_text(source) Deterministic plain text.
mdi.render_text_format(source, format) TXT, ruby, Narou, Kakuyomu, or Aozora text.
mdi.render_epub(source) EPUB 3 archive bytes.
mdi.render_docx(source) DOCX archive bytes.
epub_bytes = mdi.render_epub("# Chapter\n\nText")
with open("book.epub", "wb") as output:
    output.write(epub_bytes)

See the official Python documentation for API details, the complete MDI syntax, output formats, and architecture.

Platform support

Prebuilt wheels are published for macOS (Intel and Apple Silicon), Linux x64, and Windows x64. A source distribution is also available for other platforms with a supported Rust toolchain.

Development

The binding is tested against a locally built native extension. From this directory, use Python 3.10 or newer:

python -m pip install -e ".[test]"
python -m pytest --cov=mdi --cov-branch

The test suite covers the public Python contract, including the versioned IR, UTF-8 byte spans, diagnostics, all text exports, archive structure, type boundaries, and the stable API surface.

License

MIT

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

illusion_markdown-2.0.3.tar.gz (45.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

illusion_markdown-2.0.3-cp310-abi3-win_amd64.whl (676.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

illusion_markdown-2.0.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (902.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

illusion_markdown-2.0.3-cp310-abi3-macosx_11_0_arm64.whl (809.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

illusion_markdown-2.0.3-cp310-abi3-macosx_10_12_x86_64.whl (819.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file illusion_markdown-2.0.3.tar.gz.

File metadata

  • Download URL: illusion_markdown-2.0.3.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for illusion_markdown-2.0.3.tar.gz
Algorithm Hash digest
SHA256 bcaa73d14e93acb03376559ddd545918b3ae19ddc16ef5b301b02954c99915d8
MD5 e651248382199e1b1324f4a6e3fa54bc
BLAKE2b-256 7bb81e8ca8bc508fe5f59c1ca36e7405a288fd0f27c004bda82b4605ea7eb1ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for illusion_markdown-2.0.3.tar.gz:

Publisher: release-pypi.yml on illusions-lab/MDI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file illusion_markdown-2.0.3-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for illusion_markdown-2.0.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 70f8b80048b9326b273062c30248e1b253397c3498fd6a88d3453397a3c5bf0b
MD5 35be413483c7ac7911f0d81087cc0bfc
BLAKE2b-256 7e8d783cdecbbd3e3f542b38a80a5ec21b9122ab53b71e3e755e3b7da3f934a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for illusion_markdown-2.0.3-cp310-abi3-win_amd64.whl:

Publisher: release-pypi.yml on illusions-lab/MDI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file illusion_markdown-2.0.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for illusion_markdown-2.0.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d8637bafc1bfb5eaca9a77049ab3a3da8a13380d0879215543c7f264abeb061
MD5 635d50a8452d676e9ee414c3fe86ed2f
BLAKE2b-256 cbd39a8f5a8c05478b7404f302b78766943ca504d0a80f52e8f2e37fe9649497

See more details on using hashes here.

Provenance

The following attestation bundles were made for illusion_markdown-2.0.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pypi.yml on illusions-lab/MDI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file illusion_markdown-2.0.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for illusion_markdown-2.0.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e2e9c039664843c877c049422da17f93e7b373fb5834725870595047646c052
MD5 10cfb6fc73062f2e471a013860cdefe8
BLAKE2b-256 baf7d64f441b70a23d0af369122c53b0b3eebeb47a0fb771d43d40c853a8a582

See more details on using hashes here.

Provenance

The following attestation bundles were made for illusion_markdown-2.0.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on illusions-lab/MDI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file illusion_markdown-2.0.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for illusion_markdown-2.0.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2333473a070c8f0fe78db10f197b81a4806e386270bdf3dc2cec5defb51ac7d1
MD5 565eaf3fc408eb49a201bee9077c3817
BLAKE2b-256 b75fcf58341113f6febcce0a92a7f16a31a7c14c56bc4dc6de4ae1869d5edf42

See more details on using hashes here.

Provenance

The following attestation bundles were made for illusion_markdown-2.0.3-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release-pypi.yml on illusions-lab/MDI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page