OMNI-CORE LogoOMNI-CORE
omni-mdxomni-3D (soon)Open SourceAbout
GitHubDocumentation
OMNI-CORE

Knowledge must flow freely to shape the future.

Ecosystem

  • omni-mdx
  • omni-3D

Resources

  • Documentation
  • Interactive Playground

Legal & Open Source

  • GitHub Organization
  • Notice

TOAQ GROUP © 2024 - 2026

Released under the MIT License.

Navigation

Getting Started

  • Introduction
    • Web & Next.js
    • Python Engine
    • Build from Source
  • Syntax Guide

Web Integration

  • Next.js Integration
  • Binary AST Transfer
  • Custom Components
  • Unified & Plugins Ecosystem Integration
    • Basic App Router
    • Advanced Rendering
    • Live Client Editor

Python

  • Introduction & Core Engine
    • Basic Parsing & Traversal
    • Advanced Analysis & RAG
    • Native Qt Rendering
    • HTML & Web Rendering
    • Basic Parsing
    • Advanced Analysis
    • HTML Rendering
    • Qt Rendering

Architecture & Core

    • Design Philosophy
    • The Rendering Pipeline
    • Lexing & Tokenization
    • AST Node Design
    • Math & JSX Handling
    • Protocol Specification
    • Zero-Copy Decoding
    • Memory Lifecycle
    • WASM Bindings (Browser)
    • Node.js Native Addons
    • Python Bindings (PyO3)
  • Security
    • Benchmarks
    • Fuzzing Results
Docs
Python
Examples
Basic Parsing

Example: Basic Parsing & Traversal

Last Updated March 27, 2026

The foundation of the Omni-MDX Python engine is its ability to parse Markdown and JSX at lightning speed while keeping the memory footprint near zero. This example demonstrates how to load a document and iterate through its native AST nodes.

ℹ️ Information
Full Source Code: Clone and test this environment directly from omni-mdx-sandbox/python/basic-parsing.

Extracting Node Information

Imagine you want to parse a simple document and isolate specific JSX alerts to check their severity.

1. The Source MDX File

You have a standard MDX string containing custom components:

mdx
# System Status

The system is currently operating normally.


  Database connection **lost** at 10:42 PM.

2. The Python Extraction Script

On the Python side, you use the omni_mdx.parse() function. Because of the Zero-Copy architecture, the attributes are instantly available as a native Python dictionary.

python
import omni_mdx

def main():
    # 1. Parse the document (returns a pointer to Rust memory)
    document_source = """# System Status

The system is currently operating normally.


  Database connection **lost** at 10:42 PM.

"""
    ast = omni_mdx.parse(document_source)
    
    # 2. Filter specific JSX nodes
    # In omni_mdx, JSX component nodes use the component tag name (e.g. "Alert") as node_type.
    alerts = [node for node in ast.nodes if node.node_type == "Alert"]
    
    for alert in alerts:
        # 3. Access the native dictionary for attributes
        attrs = alert.attributes or {}
        level = attrs.get("level", "unknown")
        is_active = "active" in attrs
        
        # 4. Use text_content() to recursively strip Markdown tags (like **lost**)
        clean_message = alert.text_content().strip()
        
        status = "ONGOING" if is_active else "RESOLVED"
        print(f"[{status}] {level.upper()}: {clean_message}")

# Output: [ONGOING] CRITICAL: Database connection lost at 10:42 PM.

By leveraging the AST, you bypass the need for fragile regular expressions, accessing your document’s semantic structure safely and efficiently.

Boosted by omni-mdx native node

On this page

  • Extracting Node Information
  • 1. The Source MDX File
  • 2. The Python Extraction Script
Edit this page on GitHub

Caught a typo or want to improve the docs? Submitting a PR is the best way to help!