all2md.parsers.rtf
RTF to AST converter.
This module provides conversion from RTF documents (via pyth) to AST representation. It replaces direct markdown string generation with structured AST building.
- class all2md.parsers.rtf.RtfToAstConverter
Bases:
BaseParserConvert RTF documents (pyth Document) to AST representation.
This converter processes pyth Document objects and builds an AST that can be rendered to various markdown flavors.
- Parameters:
options (RtfOptions or None) – Conversion options
Initialize the RTF parser with options and progress callback.
- __init__(options: RtfOptions | None = None, progress_callback: Callable[[ProgressEvent], None] | None = None)
Initialize the RTF parser with options and progress callback.
- parse(input_data: str | Path | IO[bytes] | bytes) Document
Parse RTF input into an AST Document.
- Parameters:
input_data (str, Path, IO[bytes], or bytes) – RTF document to parse
- Returns:
AST Document node
- Return type:
- Raises:
ParsingError – If parsing fails or required dependencies are missing
- convert_to_ast(pyth_doc: Any) Document
Convert pyth Document to AST Document.
- Parameters:
pyth_doc (pyth.document.Document) – Pyth document object
- Returns:
AST document node
- Return type:
- extract_metadata(document: pyth.document.Document) DocumentMetadata
Extract metadata from RTF document.
- Parameters:
document (pyth.document.Document) – Parsed RTF document from pyth
- Returns:
Extracted metadata
- Return type: