mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Output: Replace self closed pre elements as they cause problems with WebKit based renderers
This commit is contained in:
parent
9ff952beae
commit
3850f64c06
@ -136,6 +136,21 @@ class EPUBOutput(OutputFormatPlugin):
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user