all2md.renderers.rtf
RTF rendering from AST using the pyth3 toolkit.
- class all2md.renderers.rtf.RtfRenderer
Bases:
NodeVisitor,BaseRendererRender AST nodes into Rich Text Format documents.
Initialize the renderer with format-specific options.
- __init__(options: RtfRendererOptions | None = None) None
Initialize the renderer with format-specific options.
- render(doc: Document, output: str | Path | IO[bytes]) None
Render a document to an RTF stream or file.
- visit_code_block(node: CodeBlock) Any
Render a fenced or indented code block as indented text paragraphs.
- visit_block_quote(node: BlockQuote) Any
Render a block quote by prefixing contained paragraphs.
- visit_definition_list(node: DefinitionList) Any
Render a definition list as paragraphs with indented descriptions.
- visit_definition_term(node: DefinitionTerm) Any
Render a definition term to a paragraph.
- visit_definition_description(node: DefinitionDescription) Any
Render a definition description’s block content.
- visit_thematic_break(node: ThematicBreak) Any
Render a thematic break as an em-dash divider.
- visit_footnote_definition(node: FootnoteDefinition) Any
Render a footnote definition with indentation.
- visit_math_block(node: MathBlock) Any
Render a display math block using its preferred representation.
- visit_math_inline(node: MathInline) Any
Render inline math using its preferred representation.
- visit_strikethrough(node: Strikethrough) Any
Render strikethrough content with the strike property.
- visit_superscript(node: Superscript) Any
Render superscript content using the superscript style.
- visit_html_inline(node: HTMLInline) Any
Render raw inline HTML as literal text.
- visit_footnote_reference(node: FootnoteReference) Any
Render a footnote reference marker.
- visit_comment(node: Comment) Any
Render a block-level comment node according to comment_mode option.
RTF supports native annotations via the annotation control word, but the pyth3 library does not expose direct support for annotations. We use bracketed text as a fallback.
- Parameters:
node (Comment) – Comment block to render
- Returns:
Pyth paragraph object with comment content, or None if ignoring
- Return type:
Any
Notes
Supports multiple rendering modes via comment_mode option: - “bracketed”: Render as [bracketed text] (default) - “ignore”: Skip comment entirely
- visit_comment_inline(node: CommentInline) Any
Render an inline comment node according to comment_mode option.
RTF supports native annotations via the annotation control word, but the pyth3 library does not expose direct support for annotations. We use bracketed inline text as a fallback.
- Parameters:
node (CommentInline) – Inline comment to render
- Returns:
List containing pyth text run with comment content, or empty list if ignoring
- Return type:
Any
Notes
Supports multiple rendering modes via comment_mode option: - “bracketed”: Render as [bracketed text] (default) - “ignore”: Skip comment entirely