From f2219c400b625b8ed8c6d5c86487e08d95357a4a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Jan 2011 15:16:08 -0700 Subject: [PATCH] MOBI Input: Fix regression that caused images placed inside svg tags to be discarded --- src/calibre/ebooks/mobi/reader.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 57f32e7131..e07418f41c 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -632,9 +632,18 @@ class MobiReader(object): attrib['class'] = cls for tag in svg_tags: - p = tag.getparent() - if hasattr(p, 'remove'): - p.remove(tag) + images = tag.xpath('descendant::img[@src]') + parent = tag.getparent() + + if images and hasattr(parent, 'find'): + index = parent.index(tag) + for img in images: + img.getparent().remove(img) + img.tail = img.text = None + parent.insert(index, img) + + if hasattr(parent, 'remove'): + parent.remove(tag) def create_opf(self, htmlfile, guide=None, root=None): mi = getattr(self.book_header.exth, 'mi', self.embedded_mi)