From e1c4e0bd454ba9a5693cd25e2907a0fda1596b07 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 18 Jan 2009 19:57:06 -0800 Subject: [PATCH] EPUB output:Map
tags that are childern of to

 

to get ADE to display them as line breaks. --- src/calibre/ebooks/epub/from_html.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 413bea4801..179c0af22b 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -128,6 +128,8 @@ class HTMLProcessor(Processor, Rationalizer): if hasattr(self.body, 'xpath'): for script in list(self.body.xpath('descendant::script')): script.getparent().remove(script) + + self.fix_markup() def convert_image(self, img): rpath = img.get('src', '') @@ -145,6 +147,17 @@ class HTMLProcessor(Processor, Rationalizer): if val == rpath: self.resource_map[key] = 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
that are children of with

 

+ if hasattr(self.body, 'xpath'): + for br in self.body.xpath('./br'): + br.tag = 'p' + br.text = u'\u00a0' def save(self): for meta in list(self.root.xpath('//meta')):