EPUB Output: Replace self closed pre elements as they cause problems with WebKit based renderers

This commit is contained in:
Kovid Goyal 2009-07-07 13:46:03 -06:00
parent 9ff952beae
commit 3850f64c06

View File

@ -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)