MCPcopy
hub / github.com/Textualize/rich / save_html

Method save_html

rich/console.py:2321–2350  ·  view source on GitHub ↗

Generate HTML from console contents and write to a file (requires record=True argument in constructor). Args: path (Union[str, PathLike[str]]): Path to write html file. theme (TerminalTheme, optional): TerminalTheme object containing console colors. clear

(
        self,
        path: Union[str, PathLike[str]],
        *,
        theme: Optional[TerminalTheme] = None,
        clear: bool = True,
        code_format: str = CONSOLE_HTML_FORMAT,
        inline_styles: bool = False,
    )

Source from the content-addressed store, hash-verified

2319 return rendered_code
2320
2321 def save_html(
2322 self,
2323 path: Union[str, PathLike[str]],
2324 *,
2325 theme: Optional[TerminalTheme] = None,
2326 clear: bool = True,
2327 code_format: str = CONSOLE_HTML_FORMAT,
2328 inline_styles: bool = False,
2329 ) -> None:
2330 """Generate HTML from console contents and write to a file (requires record=True argument in constructor).
2331
2332 Args:
2333 path (Union[str, PathLike[str]]): Path to write html file.
2334 theme (TerminalTheme, optional): TerminalTheme object containing console colors.
2335 clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``.
2336 code_format (str, optional): Format string to render HTML. In addition to '{foreground}',
2337 '{background}', and '{code}', should contain '{stylesheet}' if inline_styles is ``False``.
2338 inline_styles (bool, optional): If ``True`` styles will be inlined in to spans, which makes files
2339 larger but easier to cut and paste markup. If ``False``, styles will be embedded in a style tag.
2340 Defaults to False.
2341
2342 """
2343 html = self.export_html(
2344 theme=theme,
2345 clear=clear,
2346 code_format=code_format,
2347 inline_styles=inline_styles,
2348 )
2349 with open(path, "w", encoding="utf-8") as write_file:
2350 write_file.write(html)
2351
2352 def export_svg(
2353 self,

Callers 4

test_save_htmlFunction · 0.95
export.pyFile · 0.80
ansi.pyFile · 0.80
emoji.pyFile · 0.80

Calls 3

export_htmlMethod · 0.95
openFunction · 0.85
writeMethod · 0.45

Tested by 1

test_save_htmlFunction · 0.76