Skip to content

Commit f336ebe

Browse files
author
Maciej Rapacz
committed
fix: prepend charset meta tag to HTML in save()
Headless browsers (like Chrome) can misidentify the encoding of an HTML fragment and corrupt Unicode characters. Prepending <meta charset='utf-8'> ensures that the characters are rendered correctly in the resulting image file.
1 parent 967be02 commit f336ebe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

great_tables/_export.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ def save(
449449
file = str(Path(file).with_suffix(".png"))
450450

451451
# Get the HTML content from the displayed output
452-
html_content = as_raw_html(self)
452+
# Prepend utf-8 charset so the Chrome webdriver renders unicode correctly
453+
html_content = "<meta charset='utf-8'>" + as_raw_html(self)
453454

454455
wdriver = _get_web_driver(web_driver)
455456

0 commit comments

Comments
 (0)