Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions rendercanvas/anywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def _load_js_and_css():
js = ""
for fname in ["renderview.js", "renderview-afm.js"]:
js_path = resource_files("rendercanvas.core").joinpath(fname)
js += js_path.read_text() + "\n\n"
js += js_path.read_text(encoding="utf-8") + "\n\n"

css_path = resource_files("rendercanvas.core").joinpath("renderview.css")

return js, css_path.read_text()
return js, css_path.read_text(encoding="utf-8")


JS, CSS = _load_js_and_css()
Expand Down
4 changes: 2 additions & 2 deletions rendercanvas/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def _inject_js_and_css():
js = ""
for fname in ["renderview.js", "renderview-pyodide.js"]:
js_path = resource_files("rendercanvas.core").joinpath(fname)
js += js_path.read_text()
js += js_path.read_text(encoding="utf-8")
js = "(function () {\n{JS}\n})();".replace("JS", js) # wrap in IIFE module
script_el = document.createElement("script")
script_el.textContent = js
document.head.appendChild(script_el)

css_path = resource_files("rendercanvas.core").joinpath("renderview.css")
style_el = document.createElement("style")
style_el.textContent = css_path.read_text()
style_el.textContent = css_path.read_text(encoding="utf-8")
document.head.appendChild(style_el)


Expand Down
Loading