diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua
index 22b13625f..2ca88535d 100644
--- a/frontend/ui/widget/footnotewidget.lua
+++ b/frontend/ui/widget/footnotewidget.lua
@@ -293,8 +293,11 @@ function FootnoteWidget:init()
local padding_bottom = Size.padding.large
local htmlwidget_height = self.height - padding_top - padding_bottom
+ -- We always get balanced XHTML from crengine for HTML snippets, so we
+ -- pass is_xhtml=true to avoid side effects from MuPDF's HTML5 parser.
self.htmlwidget = ScrollHtmlWidget:new{
html_body = self.html,
+ is_xhtml = true,
css = css,
default_font_size = font_size,
width = htmlwidget_width,
diff --git a/frontend/ui/widget/htmlboxwidget.lua b/frontend/ui/widget/htmlboxwidget.lua
index 02a1cc48c..447d89472 100644
--- a/frontend/ui/widget/htmlboxwidget.lua
+++ b/frontend/ui/widget/htmlboxwidget.lua
@@ -36,7 +36,7 @@ function HtmlBoxWidget:init()
end
end
-function HtmlBoxWidget:setContent(body, css, default_font_size)
+function HtmlBoxWidget:setContent(body, css, default_font_size, is_xhtml)
-- fz_set_user_css is tied to the context instead of the document so to easily support multiple
-- HTML dictionaries with different CSS, we embed the stylesheet into the HTML instead of using
-- that function.
@@ -51,8 +51,14 @@ function HtmlBoxWidget:setContent(body, css, default_font_size)
-- https://bugs.ghostscript.com/show_bug.cgi?id=698351
html = html:gsub("%
", "
123
123
" as being plain text). local ok - ok, self.document = pcall(Mupdf.openDocumentFromText, html, "html") + ok, self.document = pcall(Mupdf.openDocumentFromText, html, is_xhtml and "xhtml" or "html") if not ok then -- self.document contains the error logger.warn("HTML loading error:", self.document) diff --git a/frontend/ui/widget/scrollhtmlwidget.lua b/frontend/ui/widget/scrollhtmlwidget.lua index ce5e5372a..038bd84ac 100644 --- a/frontend/ui/widget/scrollhtmlwidget.lua +++ b/frontend/ui/widget/scrollhtmlwidget.lua @@ -17,6 +17,7 @@ local Screen = Device.screen local ScrollHtmlWidget = InputContainer:extend{ html_body = nil, + is_xhtml = false, css = nil, default_font_size = Screen:scaleBySize(24), -- same as infofont htmlbox_widget = nil, @@ -39,7 +40,7 @@ function ScrollHtmlWidget:init() html_link_tapped_callback = self.html_link_tapped_callback, } - self.htmlbox_widget:setContent(self.html_body, self.css, self.default_font_size) + self.htmlbox_widget:setContent(self.html_body, self.css, self.default_font_size, self.is_xhtml) self.v_scroll_bar = VerticalScrollBar:new{ enable = self.htmlbox_widget.page_count > 1,