diff --git a/src/pyj/read_book/footnotes.pyj b/src/pyj/read_book/footnotes.pyj index 7acb60797b..5b0da73b25 100644 --- a/src/pyj/read_book/footnotes.pyj +++ b/src/pyj/read_book/footnotes.pyj @@ -201,7 +201,7 @@ class PopupIframeBoss: window.URL.revokeObjectURL(self.blob_url_map[name]) document.body.style.removeProperty('font-family') root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data) - self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote) + self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote, data.name) def on_clear(self, data): clear(document.head) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index a7af8b717c..52994bc3f8 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -175,7 +175,7 @@ class IframeBoss: window.URL.revokeObjectURL(self.blob_url_map[name]) document.body.style.removeProperty('font-family') root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data) - self.resource_urls = unserialize_html(root_data, self.content_loaded) + self.resource_urls = unserialize_html(root_data, self.content_loaded, None, data.name) def on_scroll_to_frac(self, data): self.to_scroll_fraction(data.frac) diff --git a/src/pyj/read_book/resources.pyj b/src/pyj/read_book/resources.pyj index 970867102b..b1a7c708da 100644 --- a/src/pyj/read_book/resources.pyj +++ b/src/pyj/read_book/resources.pyj @@ -225,7 +225,7 @@ def process_stack(stack, tag_map, ns_map, load_required, onload, resource_urls): for v'var i = node.length - 1; i >= 1; i--': # noqa: unused-local stack.push(v'[node[i], elem]') -def unserialize_html(serialized_data, proceed, postprocess_dom): +def unserialize_html(serialized_data, proceed, postprocess_dom, root_name): nonlocal hide_tooltips tag_map = serialized_data.tag_map tree = serialized_data.tree @@ -241,6 +241,13 @@ def unserialize_html(serialized_data, proceed, postprocess_dom): document.head.appendChild( E.style(type='text/css', 'html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important }') ) + if runtime.is_standalone_viewer and root_name: + if root_name.indexOf('/') > -1: + base = window.location.pathname.rpartition('/')[0] + base = f'{window.location.protocol}//{window.location.hostname}{base}/' + root_name + document.head.appendChild(E.base(href=base)) + + # Default stylesheet if not runtime.is_standalone_viewer: # for the standalone viewer the default font family is set