Skip to main content

Ultra-fast MDX rendering engine powered by Rust and WebAssembly.

Project description

omni-mdx

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

omni-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 omni-mdx

🛠️ Quick Start

1. Parsing MDX to AST

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

import omni_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 = omni_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 omni_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 omni_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 omni_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.

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-0.1.5-py3-none-win_amd64.whl (142.2 kB view details)

Uploaded Python 3Windows x86-64

omni_mdx-0.1.5-py3-none-manylinux_2_17_x86_64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

omni_mdx-0.1.5-py3-none-macosx_10_9_universal2.whl (647.7 kB view details)

Uploaded Python 3macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file omni_mdx-0.1.5-py3-none-win_amd64.whl.

File metadata

  • Download URL: omni_mdx-0.1.5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 142.2 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for omni_mdx-0.1.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 54766e613f846fdea37765f21fa5351949627b10b8e931404b42b6ada9f82742
MD5 2cf0995890cae9124eeb5d48d78e368c
BLAKE2b-256 b184b88acbba6abb12228742be0aad0b9c1393337a61e9f42404c7b5b0d122df

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-0.1.5-py3-none-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-0.1.5-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for omni_mdx-0.1.5-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c2c9d451e0f60c6817110d8e483316cc60c056df439f657188ef34ad174d32a8
MD5 0f15aea48b52a4f126559edf44eb9cca
BLAKE2b-256 7f8e17eafafa2af8df8f6535bfae3d5e0ee8766c13f9d2bb0db458eab91a78e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-0.1.5-py3-none-manylinux_2_17_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-0.1.5-py3-none-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for omni_mdx-0.1.5-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 57c434387b97d5e1e1b1a13474ef29a1c5f1e2e23169b08c2fe5e8e4daada8a3
MD5 44cde2ab13ef2d47f14a74f02b6a3e2a
BLAKE2b-256 4000f82d3a2e6708f91c84217f0982b9acefd20f075b2b7eaf6c34fa6553a30c

See more details on using hashes here.

Provenance

The following attestation bundles were made for omni_mdx-0.1.5-py3-none-macosx_10_9_universal2.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