mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB output:Map <br> tags that are childern of <body> to <p> </p> to get ADE to display them as line breaks.
This commit is contained in:
parent
6b1d2571c1
commit
e1c4e0bd45
@ -128,6 +128,8 @@ class HTMLProcessor(Processor, Rationalizer):
|
|||||||
if hasattr(self.body, 'xpath'):
|
if hasattr(self.body, 'xpath'):
|
||||||
for script in list(self.body.xpath('descendant::script')):
|
for script in list(self.body.xpath('descendant::script')):
|
||||||
script.getparent().remove(script)
|
script.getparent().remove(script)
|
||||||
|
|
||||||
|
self.fix_markup()
|
||||||
|
|
||||||
def convert_image(self, img):
|
def convert_image(self, img):
|
||||||
rpath = img.get('src', '')
|
rpath = img.get('src', '')
|
||||||
@ -145,6 +147,17 @@ class HTMLProcessor(Processor, Rationalizer):
|
|||||||
if val == rpath:
|
if val == rpath:
|
||||||
self.resource_map[key] = rpath+'_calibre_converted.jpg'
|
self.resource_map[key] = rpath+'_calibre_converted.jpg'
|
||||||
img.set('src', rpath+'_calibre_converted.jpg')
|
img.set('src', rpath+'_calibre_converted.jpg')
|
||||||
|
|
||||||
|
def fix_markup(self):
|
||||||
|
'''
|
||||||
|
Perform various markup transforms to get the output to render correctly
|
||||||
|
in the quirky ADE.
|
||||||
|
'''
|
||||||
|
# Replace <br> that are children of <body> with <p> </p>
|
||||||
|
if hasattr(self.body, 'xpath'):
|
||||||
|
for br in self.body.xpath('./br'):
|
||||||
|
br.tag = 'p'
|
||||||
|
br.text = u'\u00a0'
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
for meta in list(self.root.xpath('//meta')):
|
for meta in list(self.root.xpath('//meta')):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user