From 842d7bed2240b1db79998e5466f23a3083254bc2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Sep 2009 11:24:09 -0600 Subject: [PATCH] Fix #3513 (conversion bug in Mobi 2 Epub) --- src/calibre/ebooks/mobi/reader.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 67b1175386..a37285a47c 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -504,13 +504,23 @@ class MobiReader(object): height = attrib.pop('height').strip() if height and '<' not in height and '>' not in height and \ re.search(r'\d+', height): - styles.append('margin-top: %s' % self.ensure_unit(height)) + if tag.tag in ('table', 'td', 'tr'): + pass + elif tag.tag == 'img': + tag.set('height', height) + else: + styles.append('margin-top: %s' % self.ensure_unit(height)) if attrib.has_key('width'): width = attrib.pop('width').strip() if width and re.search(r'\d+', width): - styles.append('text-indent: %s' % self.ensure_unit(width)) - if width.startswith('-'): - styles.append('margin-left: %s' % self.ensure_unit(width[1:])) + if tag.tag in ('table', 'td', 'tr'): + pass + elif tag.tag == 'img': + tag.set('width', width) + else: + styles.append('text-indent: %s' % self.ensure_unit(width)) + if width.startswith('-'): + styles.append('margin-left: %s' % self.ensure_unit(width[1:])) if attrib.has_key('align'): align = attrib.pop('align').strip() if align: