diff --git a/src/calibre/ebooks/epub/output.py b/src/calibre/ebooks/epub/output.py index 9c542d7b2f..be096eece3 100644 --- a/src/calibre/ebooks/epub/output.py +++ b/src/calibre/ebooks/epub/output.py @@ -136,6 +136,21 @@ class EPUBOutput(OutputFormatPlugin): ''' + def workaround_webkit_quirks(self): + from calibre.ebooks.oeb.base import XPath + for x in self.oeb.spine: + root = x.data + body = XPath('//h:body')(root) + if body: + body = body[0] + + if not hasattr(body, 'xpath'): + continue + + for pre in XPath('//h:pre')(body): + if not pre.text and len(pre) == 0: + pre.tag = 'div' + def convert(self, oeb, output_path, input_plugin, opts, log): self.log, self.opts, self.oeb = log, opts, oeb @@ -148,6 +163,7 @@ class EPUBOutput(OutputFormatPlugin): self.workaround_ade_quirks() + self.workaround_webkit_quirks() from calibre.ebooks.oeb.transforms.rescale import RescaleImages RescaleImages()(oeb, opts)