all2md.renderers.rtf

RTF rendering from AST using the pyth3 toolkit.

class all2md.renderers.rtf.RtfRenderer

Bases: NodeVisitor, BaseRenderer

Render 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.

render_to_string(doc: Document) str

Render a document to an in-memory RTF string.

visit_document(node: Document) Any

Convert the root document node to a pyth document.

visit_heading(node: Heading) Any

Render a heading node with optional bold styling.

visit_paragraph(node: Paragraph) Any

Render a paragraph node to a pyth paragraph.

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_list(node: List) Any

Render a list node to a pyth bullet list.

visit_list_item(node: ListItem) Any

Render a list item, preserving task status when present.

visit_table(node: Table) Any

Render a table as a series of plain-text paragraphs.

visit_table_row(node: TableRow) Any

Render a table row to a fallback string (used internally).

visit_table_cell(node: TableCell) Any

Render a table cell to plain text.

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_html_block(node: HTMLBlock) Any

Render raw HTML blocks as literal text with a debug hint.

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.

Render a hyperlink, preserving URL metadata.

visit_image(node: Image) Any

Render an image as descriptive text with optional target URL.

visit_text(node: Text) Any

Render a plain text leaf node.

visit_emphasis(node: Emphasis) Any

Render emphasized content with italic styling.

visit_strong(node: Strong) Any

Render strong content with bold styling.

visit_code(node: Code) Any

Render inline code as a literal text run.

visit_line_break(node: LineBreak) Any

Render a soft or hard line break as a newline character.

visit_strikethrough(node: Strikethrough) Any

Render strikethrough content with the strike property.

visit_subscript(node: Subscript) Any

Render subscript content using the subscript style.

visit_superscript(node: Superscript) Any

Render superscript content using the superscript style.

visit_underline(node: Underline) Any

Render underlined content using the underline 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