Skip to main content

toaq-mdx

A blazingly fast, headless MDX engine for Python, powered by a Rust core.

toaq-mdx provides a bridge between the high-performance pulldown-cmark Rust parser and native Python applications. It parses MDX (Markdown + JSX) into a deeply manipulable Abstract Syntax Tree (AST) and offers zero-dependency native rendering solutions for both the Web (HTML/KaTeX) and Desktop (PyQt5/Matplotlib).

🚀 Features

  • Blazing Fast: The core parsing is handled by a pre-compiled Rust binary.
  • Headless AST: Manipulate Markdown and JSX tags as pure Python objects (AstNode).
  • Zero-HTML Desktop Rendering: Render rich text, complex layouts, and math equations natively in PyQt5 without relying on heavy WebEngine components.
  • Universal Math Support:
    • Generates data-math attributes for KaTeX on the web.
    • Generates native QPixmap images using Matplotlib for desktop apps.
  • Fat Wheel Distribution: The Rust binary is bundled directly into the Python package. No Rust toolchain is required for end-users.

📦 Installation

pip install toaq-mdx

🛠️ Quick Start

1. Parsing MDX to AST

The core feature of toaq-mdx is transforming text into a structured, easily searchable AST.

import toaq_mdx

mdx_content = """
# Physics 101
The kinetic energy is defined as:
$$E_k = \\frac{1}{2}mv^2$$

<Note type="warning">Check your units!</Note>
"""

# Parse the text into a list of AstNode objects
nodes = toaq_mdx.parse(mdx_content)

# Easily search the AST
math_blocks = [n for n in nodes if n.node_type == "BlockMath"]
print(math_blocks[0].content) # Output: E_k = \frac{1}{2}mv^2

2. Web Rendering (HTML)

Generate clean, highly customizable HTML, perfectly suited for modern web frameworks like Next.js or FastAPI.

from toaq_mdx import HtmlRenderer, parse

nodes = parse("<Speaker name='Leon'>Welcome to the show.</Speaker>")

# Register custom rendering logic for JSX components
def render_speaker(node, ctx):
    name = node.attr_text("name")
    return f'<div class="speaker-tag">{name}</div><p>{node.text_content()}</p>'

renderer = HtmlRenderer(components={"Speaker": render_speaker})
html_output = renderer.render(nodes)

3. Native Desktop Rendering (PyQt5)

Render MDX content directly into native Qt Widgets. Math equations are seamlessly converted to high-quality images via Matplotlib.

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
from toaq_mdx import OmniMDX, parse

app = QApplication(sys.argv)
window = QWidget()
layout = QVBoxLayout(window)

nodes = parse("# Hello\\nNative rendering without WebViews!")

# OmniMDX handles the Qt layout generation
engine = OmniMDX()
widget = engine.render_qt(nodes, parent=window)

layout.addWidget(widget)
window.show()
sys.exit(app.exec_())

🧠 Advanced AST Manipulation

Because the parser generates a typed AstNode tree, it is an ideal tool for large-scale text analysis, data extraction, or automated moderation.

For instance, when processing researcher submissions or generating structured vocal datasets for distinct podcast series, you can programmatically extract specific nodes while ignoring the rest of the document formatting:

from toaq_mdx import parse

script = """
# Episode 4: Quantum Mechanics

<Speaker name="Dr. Aris" voiceId="v2">
We must look closer at the probability wave.
</Speaker>

<Speaker name="Leon" voiceId="v1">
Are you certain?
</Speaker>
"""

ast = parse(script)

# Extract dialogue for Text-To-Speech (TTS) dataset generation
dataset_entries = []
for node in ast:
    if node.node_type == "Speaker":
        dataset_entries.append({
            "character": node.attr_text("name"),
            "voice_profile": node.attr_text("voiceId"),
            "text": node.text_content().strip()
        })

import json
print(json.dumps(dataset_entries, indent=2))

🏗️ Architecture

  • parser.py: High-level wrapper calling the Rust _core.pyd binary.

  • ast.py: Python dataclasses representing the parsed nodes and attributes.

  • renderer.py: Web-ready HTML generator.

  • qt_renderer.py / engine.py: Native PyQt5 widget generator.

  • math_render.py: Utilites for converting LaTeX strings to Unicode or QPixmap.

Release files for toaq-mdx 0.1.3

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

Built distributions (wheels)

Table of built distributions (wheels) for toaq-mdx 0.1.3
File Interpreter ABI Platform
toaq_mdx-0.1.3-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
toaq_mdx-0.1.3-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
toaq_mdx-0.1.3-py3-none-macosx_10_9_universal2.whl Python 3 none macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size:2.5 MB

Release files / toaq_mdx-0.1.3-py3-none-win_amd64.whl

Download URL toaq_mdx-0.1.3-py3-none-win_amd64.whl
Size 142.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
68399952574b38604afc3116fa47e9547b5b6ae535616aa36be619f0b703a1e5
BLAKE2b-256 checksum
How to use checksums
e798618bc32f8ceed0d633e2864dc58f23aea1fabea5d578d07705d491fffa1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / toaq_mdx-0.1.3-py3-none-manylinux_2_17_x86_64.whl

Download URL toaq_mdx-0.1.3-py3-none-manylinux_2_17_x86_64.whl
Size 1.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
48aea9664a1463c6ab5b562dde62eb77adf17fff8ddfdf580b23fdd667f624c9
BLAKE2b-256 checksum
How to use checksums
0589a699ec722526350b1fbec16b9c419165a1f86f16c5c864b86657ecf52906
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / toaq_mdx-0.1.3-py3-none-macosx_10_9_universal2.whl

Download URL toaq_mdx-0.1.3-py3-none-macosx_10_9_universal2.whl
Size 650.4 kB
Tags Python 3 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
19f62eff05717484249b6e9b62ecd1b5c3b50aee56ccd276c73196e2ee68f2de
BLAKE2b-256 checksum
How to use checksums
e208c8a8e141f73277ea0b607a06e6681638de416630c7bbac4a3f918cd93481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

3 release files

0.1.2

3 release files

0.1.1

3 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