From fbdac2f78f487ea1ed9d2669c31d2a7864e49ee7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 22 Jan 2009 18:53:49 -0800 Subject: [PATCH] EPUB Output:Improve handling of
tags that are children of --- src/calibre/ebooks/epub/from_html.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index e0224cea88..722b6cd4e3 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -153,11 +153,27 @@ class HTMLProcessor(Processor, Rationalizer): Perform various markup transforms to get the output to render correctly in the quirky ADE. ''' - # Replace
that are children of with

 

+ # Replace
that are children of as ADE doesn't handle them if hasattr(self.body, 'xpath'): for br in self.body.xpath('./br'): + if br.getparent() is None: + continue + try: + sibling = br.itersiblings().next() + except: + sibling = None br.tag = 'p' br.text = u'\u00a0' + if (br.tail and br.tail.strip()) or sibling is None or \ + getattr(sibling, 'tag', '') != 'br': + br.set('style', br.get('style', '')+'; margin: 0pt; border:0pt; height:0pt') + else: + sibling.getparent().remove(sibling) + if sibling.tail: + if not br.tail: + br.tail = '' + br.tail += sibling.tail + if self.opts.profile.remove_object_tags: for tag in self.root.xpath('//embed'):