Skip to main content

Module export

Module export 

Source
Expand description

HTML, SVG, and plain-text export with 4 preset terminal color themes. HTML and SVG export — equivalent to Rich’s _export_format.py and Console export methods.

Converts rendered console output into HTML and SVG documents, preserving colors, styles, and layout. Uses TerminalTheme to map ANSI colors to CSS-compatible RGB values.

Structs§

ExportHtmlOptions
Options for HTML export.
ExportSvgOptions
Options for SVG export.
ExportTextOptions
Options for plain-text export (strips ANSI escape codes).
ExportTheme
A terminal color theme used for HTML/SVG export.

Constants§

CONSOLE_HTML_FORMAT
The HTML document template used by export_html.
CONSOLE_SVG_FORMAT
The SVG document template used by export_svg.
EXPORT_THEME_DIMMED_MONOKAI
Dimmed Monokai variant – lower contrast, suitable for comfortable reading.
EXPORT_THEME_MONOKAI
Monokai-inspired dark theme for HTML/SVG export.
EXPORT_THEME_NIGHT_OWLISH
Night Owl-inspired dark theme with deep blue background.
EXPORT_THEME_SVG
Light theme with white background, suitable for SVG export snippets.

Functions§

escape_html
Escape special HTML characters in text.
escape_xml
Escape special XML characters (&, <, >, ", ') in text.
export_html
Generate a full HTML document from rendered terminal output.
export_svg
Generate a full SVG document from rendered terminal output.
export_text
Export text, optionally stripping ANSI escape sequences. Returns plain text.
save_html
Save rendered output as an HTML file.
save_svg
Save rendered output as an SVG file.
save_text
Save text output to a file, optionally stripping ANSI escape sequences.
segments_to_html
Convert Rich styled segments to HTML with inline CSS spans.
strip_ansi_escapes
Strip ANSI escape sequences from text, returning plain text.