Skip to main content

Ultra-fast MDX rendering engine powered by Rust.

Project description

omni-mdx

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

omni-mdx provides a high-performance bridge between the 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).

⚡ Key Features

  • 🚀 Blazing Fast: Parsing is handled by a pre-compiled Rust binary. Experience performance up to 10x faster than pure Python parsers.
  • 🧠 Headless AST: Manipulate Markdown and JSX tags as pure Python objects (AstNode). Perfect for data extraction and content analysis.
  • 🖼️ Zero-HTML Desktop Rendering: Render rich text, complex layouts, and math equations natively in PyQt5 without the overhead of heavy WebEngine/Chromium components.
  • 📐 Universal Math Support:
    • Web: Generates data-math attributes compatible with KaTeX.
    • Desktop: Generates high-quality native images via Matplotlib with automatic Unicode fallback.
  • 📦 Fat Wheel Distribution: The Rust binary is bundled directly into the Python package. No Rust toolchain required for end-users.

📦 Installation

pip install omni-mdx

# Optional: Required for high-quality Desktop math rendering
pip install matplotlib PyQt5

🛠️ Quick Start

1. Parsing MDX to AST

The core strength of omni-mdx is transforming raw text into a structured, searchable tree.

import omni_mdx

mdx_content = r"""
# Physics 101
The kinetic energy is defined as:
$$\zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s}$$

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

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

# Search the AST for specific elements
math_blocks = [n for n in nodes if n.node_type == "BlockMath"]
if math_blocks:
    print(f"Formula found: {math_blocks[0].content}") 
    # Output: \zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s}

2. Web Rendering (HTML)

Generate clean, standards-compliant HTML for FastAPI, Flask, or static site generators.

from omni_mdx import render_html, 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"><b>{name}:</b> {node.text_content()}</div>'

html_output = render_html(nodes, components={"Speaker": render_speaker})

3. Native Desktop Rendering (PyQt5)

Render MDX content directly into native Qt Widgets. No browser engine needed.

from PyQt5.QtWidgets import QScrollArea
from omni_mdx.qt_renderer import QtRenderer

# 1. Parse content
nodes = omni_mdx.parse("# Hello Native!")

# 2. Render to Widget
renderer = QtRenderer()
content_widget = renderer.render(nodes)

# 3. Add to your UI (using a ScrollArea is recommended)
scroll = QScrollArea()
scroll.setWidget(content_widget)
scroll.setWidgetResizable(True)

🧠 Advanced AST Manipulation

Because omni-mdx generates a typed AstNode tree, it is an ideal tool for large-scale text analysis, TTS (Text-To-Speech) dataset generation, or automated content moderation.

from omni_mdx import parse

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

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

nodes = parse(script)

# Extract dialogue for dataset generation
dataset = []
for node in nodes:
    if node.node_type == "Speaker":
        dataset.append({
            "character": node.attr_text("name"),
            "voice_profile": node.attr_text("voiceId"),
            "text": node.text_content().strip()
        })

print(dataset[0]["text"]) # "We must look closer at the probability wave."

🏗️ Architecture

Module Description
core_interface Bridge to the native Rust _core binary.
renderer High-performance HTML generator.
qt_renderer Native PyQt5 layout engine (uses a custom FlowLayout).
math_render LaTeX logic: Unicode mapping & Matplotlib integration.

🤝 Contributing

This package is part of the TOAQ open-source ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

omni_mdx-1.0.0-cp313-cp313-win_amd64.whl (630.9 kB view details)

Uploaded CPython 3.13Windows x86-64

omni_mdx-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl (815.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

omni_mdx-1.0.0-cp313-cp313-macosx_11_0_arm64.whl (711.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file omni_mdx-1.0.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: omni_mdx-1.0.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 630.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for omni_mdx-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 979115defc5cd76ff897c4c3dfdb52e06c7e5c3bdc5a09ca8e08b2206f437075
MD5 105d2095cafe9fd81855e4cdc946053d
BLAKE2b-256 0ae0b8ea31f875332240df3a9b5ff42d2d245ce8df37d64933f0c67b9a9c7535

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-1.0.0-cp313-cp313-win_amd64.whl:

Publisher: publish-python.yml on TOAQ-oss/omni-mdx-core

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

File details

Details for the file omni_mdx-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for omni_mdx-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5ebd71c73c9e9503c218ef44033b7e3c62c1f1d97b5c1658527a569958673390
MD5 b8a9f2a9a1d745f6ede0a8a5f955ec1d
BLAKE2b-256 e2f0941b2daa0841e0ed745e19af073c8b5706462bb996022d15419773659da8

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: publish-python.yml on TOAQ-oss/omni-mdx-core

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

File details

Details for the file omni_mdx-1.0.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for omni_mdx-1.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc0bd58f299e9951d7b7c8d1f3828c45d1c9e8781afdd5d5c78d204eee3bf514
MD5 3f0b9777b55ea35b6d3f8a539528f891
BLAKE2b-256 695462fbc6b61ed006c8765007b611a04dfa32477ce8aa4f1e03c48d6bce71cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-1.0.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish-python.yml on TOAQ-oss/omni-mdx-core

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