From ac6ba99ea9be8fa195edfb50fca5fa7d160e7f87 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Nov 2009 18:46:36 -0700 Subject: [PATCH] Fix #4060 (Bad position of images in EPUB file) --- src/calibre/ebooks/odt/input.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/ebooks/odt/input.py b/src/calibre/ebooks/odt/input.py index f83cd34760..1184148e80 100644 --- a/src/calibre/ebooks/odt/input.py +++ b/src/calibre/ebooks/odt/input.py @@ -74,10 +74,18 @@ class ODTInput(InputFormatPlugin): # about them from calibre.ebooks.oeb.base import XPath, XHTML path = XPath('//h:p/h:div') + path2 = XPath('//h:div[@style]/h:img[@style]') for item in oeb.spine: root = item.data if not hasattr(root, 'xpath'): continue for div in path(root): div.getparent().tag = XHTML('div') + # This construct doesn't render well in HTML + for img in path2(root): + div = img.getparent() + if 'position:relative' in div.attrib['style'] and len(div) == 1 \ + and 'img' in div[0].tag: + del div.attrib['style'] +