MOBI Input: Fix regression that caused images placed inside svg tags to be discarded

This commit is contained in:
Kovid Goyal 2011-01-13 15:16:08 -07:00
parent 76c53ca61f
commit f2219c400b

View File

@ -632,9 +632,18 @@ class MobiReader(object):
attrib['class'] = cls attrib['class'] = cls
for tag in svg_tags: for tag in svg_tags:
p = tag.getparent() images = tag.xpath('descendant::img[@src]')
if hasattr(p, 'remove'): parent = tag.getparent()
p.remove(tag)
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): def create_opf(self, htmlfile, guide=None, root=None):
mi = getattr(self.book_header.exth, 'mi', self.embedded_mi) mi = getattr(self.book_header.exth, 'mi', self.embedded_mi)