Markdown Export¶
Markdown export is intentionally lossy where Markdown cannot represent RTF semantics directly. Options allow selected formatting to be preserved with HTML, including colors, fonts, annotation rendering, and complex tables.
from rtfstruct import MarkdownOptions, parse_rtf
document = parse_rtf(r"{\rtf1\ansi Hello}")
markdown = document.to_markdown(options=MarkdownOptions(preserve_colors=True))
- class rtfstruct.MarkdownOptions(preserve_colors=True, preserve_fonts=False, preserve_font_sizes=False, annotations='blockquote', complex_tables='html')[source]¶
Markdown export configuration placeholder.
- Parameters:
preserve_colors (bool)
preserve_fonts (bool)
preserve_font_sizes (bool)
annotations (str)
complex_tables (str)
- rtfstruct.to_markdown(document, options=None)[source]¶
Export a document AST to Markdown.
- Parameters:
document (Document) – Document AST to export.
options (MarkdownOptions | None) – Optional Markdown export configuration.
- Returns:
Markdown string.
- Return type:
str
Markdown exporter.
Markdown is a lossy backend and must not shape the AST. This skeleton exporter exists for API completeness while JSON and parser behavior are still stabilizing.