Expand description
Exporting rendered output to HTML.
Port of rich/console.py’s export_html + the _export_format.py template.
Turns a recorded stream of Segments (captured via
Console::export_html) into a
self-contained HTML document, using a TerminalTheme to resolve colors.
Both variants are ported: inline_styles (each span carries its own
style="…") and the CSS-class stylesheet, with links and code_format.
Structs§
- Export
Format Error - A
code_formattemplate that Python’sstr.formatwould reject: an unknown field (KeyError), a positional or formatted field, or an unmatched brace (ValueError).
Constants§
- CONSOLE_
HTML_ FORMAT - The HTML document template. Port of
_export_format.CONSOLE_HTML_FORMAT, verbatim: a Python format string, so literal braces are doubled. Pass it (or your own, as upstream’scode_format=) toexport_html_with.
Functions§
- export_
html_ classes - Render
segmentsto a self-contained HTML document using CSS classes and a generated stylesheet. Port ofConsole.export_html(inline_styles=False)(upstream’s default). Distinct styles are numbered.r1,.r2, … in the order first seen. - export_
html_ inline - Render
segmentsto a self-contained HTML document with inline styles. Port ofConsole.export_html(inline_styles=True). - export_
html_ with - Render
segmentsto HTML with every option of upstream’sConsole.export_html:code_formatreplacesCONSOLE_HTML_FORMAT(fields{code},{stylesheet},{foreground},{background}), andinline_styleschoosesstyle="…"attributes over a class stylesheet. - format_
template - Substitute
{name}fields in a Python format string, with{{and}}standing for literal braces: the subset ofstr.formatupstream’s export templates use. Conversions (!r) and format specs (:>10) are refused.