Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use full html page in show() for correct utf-8 display #458

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions great_tables/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,23 @@

"""

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_()

Check warning on line 106 in great_tables/_export.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_export.py#L106

Added line #L106 was not covered by tests

# 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)

Check warning on line 113 in great_tables/_export.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_export.py#L113

Added line #L113 was not covered by tests
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")

Check warning on line 116 in great_tables/_export.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_export.py#L116

Added line #L116 was not covered by tests

# create a server that closes after 1 request ----
server = _create_temp_file_server(f_path)
Expand Down
Loading