parse-rtf is a bounded, source-aware Rich Text Format (RTF 1) parser for
Python 3.14+. It has no runtime dependencies.
from parse_rtf import loads
document = loads(r"{\rtf1\ansi Hello, {\b world}!\par}")
print(document.text) # Hello, world!\nDocument.source preserves the exact input. Document.root is an immutable
syntax tree of groups, literal text, control words and symbols, hexadecimal
bytes, and opaque binary data. Every node has a SourceSpan with source offsets
and one-based line/column positions. Document.text provides a safe plain-text
projection; non-text destinations and formatting controls remain available in
the syntax tree. Non-fatal limitations are reported in Document.diagnostics.
The parser enforces configurable input-size, nesting, and node limits. See supported syntax and API and security boundaries.
uv sync --locked
uv run --frozen python -W error::ResourceWarning -m pytest -q
uv run --frozen python scripts/check_distribution.py --output-dir distThe distribution is named parse-rtf; the Python import package is
parse_rtf.
See release instructions for trusted PyPI publishing setup.