Skip to content

Commit

Permalink
Related to Issue posit-dev#518: Fixes the problem with special charac…
Browse files Browse the repository at this point in the history
…ter encoding when using .save() by reverting to earlier approach (prior to commit cccee66) where temporary html file was created and sent to browser rather than doing base64 URL encoding.
  • Loading branch information
phimad committed Jan 30, 2025
1 parent c983857 commit cef5b6b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions great_tables/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,18 @@ def save(
wdriver = _get_web_driver(web_driver)

# run browser ----
with wdriver(debug_port=debug_port) as headless_browser:
with (
tempfile.TemporaryDirectory() as tmp_dir,
wdriver(debug_port=debug_port) as headless_browser,
):

# Write the HTML content to the temp file
with open(f"{tmp_dir}/table.html", "w", encoding=encoding) as temp_file:
temp_file.write(html_content)

# Open the HTML file in the headless browser
headless_browser.set_window_size(*window_size)
encoded = base64.b64encode(html_content.encode(encoding=encoding)).decode(encoding=encoding)
headless_browser.get(f"data:text/html;base64,{encoded}")
headless_browser.get("file://" + temp_file.name)

_save_screenshot(headless_browser, scale, file, debug=_debug_dump)

Expand Down

0 comments on commit cef5b6b

Please sign in to comment.