Skip to main content

Deterministic document parser for AI agents and LLM output

Project description

pyld

PyPI Python

Deterministic document parser for AI agents and LLM output. Python bindings for the Rust litedoc-core library.

Install

pip install litedoc-py

Usage

import pyld

# Parse a document
doc = pyld.parse("""
# Hello World

This is a **paragraph** with *formatting*.

::list
- First item
- Second item
::
""")

# Iterate over blocks
for block in doc.blocks:
    match block:
        case pyld.Heading(level=level, content=content):
            print(f"H{level}: {content}")
        case pyld.Paragraph(content=content):
            print(f"Paragraph: {content}")
        case pyld.List(items=items):
            print(f"List with {len(items)} items")

# Parse with error recovery
result = pyld.parse_with_recovery("""
::list
- Unclosed list
""")

print(f"Blocks: {len(result.document.blocks)}")
print(f"Errors: {len(result.errors)}")
print(f"OK: {result.ok}")

API

Functions

  • parse(input, profile=None) - Parse a string, raises ValueError on error
  • parse_with_recovery(input, profile=None) - Parse with error recovery, always returns a result

Classes

  • Parser(profile=None) - Reusable parser instance
  • Document - Parsed document with blocks, metadata, profile
  • ParseResult - Result with document, errors, ok

Profiles

  • Profile.Litedoc - Full LiteDoc syntax (default)
  • Profile.Md - CommonMark + GFM
  • Profile.MdStrict - Strict CommonMark

Block Types

Heading, Paragraph, List, CodeBlock, Callout, Quote, Figure, Table, Footnotes, MathBlock, ThematicBreak, HtmlBlock, RawBlock

Inline Types

Text, Emphasis, Strong, Strikethrough, CodeSpan, Link, AutoLink, FootnoteRef, HardBreak, SoftBreak

License

Apache-2.0

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.

litedoc_py-0.1.0-cp312-cp312-win_amd64.whl (177.5 kB view details)

Uploaded CPython 3.12Windows x86-64

litedoc_py-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (279.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

litedoc_py-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (294.0 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

litedoc_py-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (312.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file litedoc_py-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for litedoc_py-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d8462e8dd4960781e0eedb758f6021346825ce46085549cdaa72be9736bd7da0
MD5 d23c59dfa01a17ff06a56c7b60db82ac
BLAKE2b-256 ca80aa09d7893b075c2bf4192d77e39231f090fae8ea1db990e1ae92b7a4ffcf

See more details on using hashes here.

File details

Details for the file litedoc_py-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for litedoc_py-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2df43310032f3bccc41d51ebdf0dde7eafaf2fc5ebd35f2b0fa4a990fa5886e2
MD5 f9261f7842656d9d6a393513c40613cd
BLAKE2b-256 a39a6396e20308dd47e95daa59a3c02449e72d9b29cd709c0958ec8fc2444465

See more details on using hashes here.

File details

Details for the file litedoc_py-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for litedoc_py-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f9e0dce9ead6b0b04f41a40da15f702d6938a3adf54c8f200aba8b1647cedd7b
MD5 4c00fe341c1ea1d37df5d1656e1ab499
BLAKE2b-256 f4b5106c45b436748ed8b05688f753cac306f24fc3ed0d8b1762c82436b95451

See more details on using hashes here.

File details

Details for the file litedoc_py-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for litedoc_py-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9cd1dd01d9c5b30c274d3b6994cec45f81a34c97fabfaafa005f4420d9e04ba
MD5 32e4adc9359a24736b64ed46ff994e55
BLAKE2b-256 df50f958fb844ca881f8afe89f1c4f5fb50346a035260b09d3b21749dde239ef

See more details on using hashes here.

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