Deterministic document parser for AI agents and LLM output
Project description
pyld
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, raisesValueErroron errorparse_with_recovery(input, profile=None)- Parse with error recovery, always returns a result
Classes
Parser(profile=None)- Reusable parser instanceDocument- Parsed document withblocks,metadata,profileParseResult- Result withdocument,errors,ok
Profiles
Profile.Litedoc- Full LiteDoc syntax (default)Profile.Md- CommonMark + GFMProfile.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
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 litedoc_py-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: litedoc_py-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 177.5 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8462e8dd4960781e0eedb758f6021346825ce46085549cdaa72be9736bd7da0
|
|
| MD5 |
d23c59dfa01a17ff06a56c7b60db82ac
|
|
| BLAKE2b-256 |
ca80aa09d7893b075c2bf4192d77e39231f090fae8ea1db990e1ae92b7a4ffcf
|
File details
Details for the file litedoc_py-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: litedoc_py-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 279.0 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2df43310032f3bccc41d51ebdf0dde7eafaf2fc5ebd35f2b0fa4a990fa5886e2
|
|
| MD5 |
f9261f7842656d9d6a393513c40613cd
|
|
| BLAKE2b-256 |
a39a6396e20308dd47e95daa59a3c02449e72d9b29cd709c0958ec8fc2444465
|
File details
Details for the file litedoc_py-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: litedoc_py-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 294.0 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9e0dce9ead6b0b04f41a40da15f702d6938a3adf54c8f200aba8b1647cedd7b
|
|
| MD5 |
4c00fe341c1ea1d37df5d1656e1ab499
|
|
| BLAKE2b-256 |
f4b5106c45b436748ed8b05688f753cac306f24fc3ed0d8b1762c82436b95451
|
File details
Details for the file litedoc_py-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: litedoc_py-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 312.0 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9cd1dd01d9c5b30c274d3b6994cec45f81a34c97fabfaafa005f4420d9e04ba
|
|
| MD5 |
32e4adc9359a24736b64ed46ff994e55
|
|
| BLAKE2b-256 |
df50f958fb844ca881f8afe89f1c4f5fb50346a035260b09d3b21749dde239ef
|