From 58436b16cef9ba13de214c6e13b93e09acef7be4 Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Mon, 23 Sep 2024 14:05:04 -0400 Subject: [PATCH] fix: use full html page in show() for correct utf-8 display --- great_tables/_export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/great_tables/_export.py b/great_tables/_export.py index 54189d26b..cddce58e1 100644 --- a/great_tables/_export.py +++ b/great_tables/_export.py @@ -97,22 +97,23 @@ def show( """ - html = self._repr_html_() - if target == "auto": target = _infer_render_target() if target == "notebook": from IPython.core.display import display_html + html = self._repr_html_() + # https://github.com/ipython/ipython/pull/10962 display_html( # pyright: ignore[reportUnknownVariableType] html, raw=True, metadata={"text/html": {"isolated": True}} ) elif target == "browser": + html = self.as_raw_html(make_page=True) with tempfile.TemporaryDirectory() as tmp_dir: f_path = Path(tmp_dir) / "index.html" - f_path.write_text(html) + f_path.write_text(html, encoding="utf-8") # create a server that closes after 1 request ---- server = _create_temp_file_server(f_path)