Ultra-fast MDX rendering engine powered by Rust.
Project description
omni-mdx
The high-performance MDX engine for Python, powered by a native Rust core.
pip install omni-mdx
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Architecture
- Compatibility
- Security
- Contribute
- License
What is this?
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).
When should I use this?
- Extreme Performance: You need to parse large amounts of MDX content without blocking the Python GIL, thanks to the native Rust core.
- Data Mining & AI: You want to extract structured data (formulas, metadata, components) from MDX for LLM ingestion or indexing.
- Native Desktop Apps: You are building a PyQt5 or PySide application and need to render rich Markdown and Math equations without the overhead of a heavy WebEngine/Chromium component.
- Scientific Publishing: You need robust, built-in support for GFM Tables and KaTeX/LaTeX math.
Install
The package is distributed as a Fat Wheel, meaning the Rust binary is bundled directly. No Rust toolchain is required for installation.
pip install omni-mdx
# Optional: Required for high-quality Desktop math rendering
pip install matplotlib PyQt5
Use
1. Parsing to AST
Transform 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 returns an MdxAstRoot object
ast = omni_mdx.parse(mdx_content)
# Nodes are accessible via ast.nodes
for node in ast.nodes:
if node.node_type == "BlockMath":
print(f"Formula found: {node.attributes.get('data-math')}")
2. Web Rendering (HTML)
Generate clean, standards-compliant HTML.
from omni_mdx import render_html, parse
nodes = parse("<Speaker name='Leon'>Welcome to the show.</Speaker>").nodes
# Register custom rendering logic for JSX components
def render_speaker(node, ctx):
name = node.attributes.get("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.
from PyQt5.QtWidgets import QScrollArea
from omni_mdx.qt_renderer import QtRenderer
import omni_mdx
# 1. Parse and render
nodes = omni_mdx.parse("# Hello Native!").nodes
renderer = QtRenderer()
content_widget = renderer.render(nodes)
# 2. Add to your UI
scroll = QScrollArea()
scroll.setWidget(content_widget)
scroll.setWidgetResizable(True)
API
omni_mdx.parse(source: str) -> MdxAstRoot
Parses the MDX source string into an AST root.
- Returns: An
MdxAstRootcontaining a list ofMdxNodeobjects.
MdxNode Properties
node_type: The type of the node (e.g., "h1", "text", "BlockMath").content: The raw content of the node.attributes: A dictionary of JSX props or math metadata.children: A list of childMdxNodeobjects.is_component: Boolean indicating if the node is a JSX component.
Architecture
Omni-MDX utilizes a "Bridge" architecture. The heavy parsing is performed in Rust, producing a high-performance tree. This tree is then wrapped in a Python layer that provides a familiar, typed API for manipulation and rendering.
Compatibility
- Python: 3.11+.
- Operating Systems: Linux (x86_64, aarch64), macOS (Intel, Apple Silicon), Windows (x86_64).
- GUI Frameworks: Optimized for PyQt5 but compatible with any logic that can ingest the AST.
Security
The Rust core provides a safety layer against common regex-based DoS attacks found in many pure-Python parsers. For HTML rendering, ensure your custom components properly sanitize any raw user input if necessary.
Contribute
This package is part of the TOAQ open-source ecosystem. Current Status:
- Python Layer Coverage: 88.10%.
- Core Rust Coverage: 81.29%.
See the Contribution Guide to get started with local development and maturin.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omni_mdx-1.1.1.dev1776364101-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: omni_mdx-1.1.1.dev1776364101-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 641.4 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2675f68b2c64a3e7d01853c1d98ff11e5dace2fe18195e4f1392646e9009832e
|
|
| MD5 |
02e9d3595f3ccda5a1630b6d56140ff5
|
|
| BLAKE2b-256 |
9ed4752ad10220a28b97190a4e2af4c4da629362439848decbdc4e6d096de662
|
Provenance
The following attestation bundles were made for omni_mdx-1.1.1.dev1776364101-cp313-cp313-win_amd64.whl:
Publisher:
publish-python.yml on TOAQ-oss/omni-mdx-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_mdx-1.1.1.dev1776364101-cp313-cp313-win_amd64.whl -
Subject digest:
2675f68b2c64a3e7d01853c1d98ff11e5dace2fe18195e4f1392646e9009832e - Sigstore transparency entry: 1319980698
- Sigstore integration time:
-
Permalink:
TOAQ-oss/omni-mdx-core@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Branch / Tag:
refs/heads/canary - Owner: https://github.com/TOAQ-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Trigger Event:
push
-
Statement type:
File details
Details for the file omni_mdx-1.1.1.dev1776364101-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: omni_mdx-1.1.1.dev1776364101-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 826.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d97758e72e4370d08da0725f2b1f0a809283a2ee1528ba0041e440f1dfc0c820
|
|
| MD5 |
270920d092493b27c6656ecd798d7e40
|
|
| BLAKE2b-256 |
79713381da9a30a7d9296a7d009fbb113ac080d2488f3b0fdac9585b31b8178b
|
Provenance
The following attestation bundles were made for omni_mdx-1.1.1.dev1776364101-cp313-cp313-manylinux_2_34_x86_64.whl:
Publisher:
publish-python.yml on TOAQ-oss/omni-mdx-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_mdx-1.1.1.dev1776364101-cp313-cp313-manylinux_2_34_x86_64.whl -
Subject digest:
d97758e72e4370d08da0725f2b1f0a809283a2ee1528ba0041e440f1dfc0c820 - Sigstore transparency entry: 1319980784
- Sigstore integration time:
-
Permalink:
TOAQ-oss/omni-mdx-core@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Branch / Tag:
refs/heads/canary - Owner: https://github.com/TOAQ-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Trigger Event:
push
-
Statement type:
File details
Details for the file omni_mdx-1.1.1.dev1776364101-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: omni_mdx-1.1.1.dev1776364101-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 720.5 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00a9739279de9911e71652526b425ce04157702cd2debdeaf501eadfa604357
|
|
| MD5 |
e63063f09d9ca55e368fee8cab77ec3c
|
|
| BLAKE2b-256 |
30b4311d7fefcb9e4d56b76d016b2ae0ed47b5b3f735368db90eb4df55e0f317
|
Provenance
The following attestation bundles were made for omni_mdx-1.1.1.dev1776364101-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish-python.yml on TOAQ-oss/omni-mdx-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_mdx-1.1.1.dev1776364101-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
e00a9739279de9911e71652526b425ce04157702cd2debdeaf501eadfa604357 - Sigstore transparency entry: 1319980895
- Sigstore integration time:
-
Permalink:
TOAQ-oss/omni-mdx-core@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Branch / Tag:
refs/heads/canary - Owner: https://github.com/TOAQ-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@b5e1d4dbed892de47f607ba843ed675c5682fb8c -
Trigger Event:
push
-
Statement type: