mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #4060 (Bad position of images in EPUB file)
This commit is contained in:
parent
d51e3eff2d
commit
ac6ba99ea9
@ -74,10 +74,18 @@ class ODTInput(InputFormatPlugin):
|
|||||||
# about them
|
# about them
|
||||||
from calibre.ebooks.oeb.base import XPath, XHTML
|
from calibre.ebooks.oeb.base import XPath, XHTML
|
||||||
path = XPath('//h:p/h:div')
|
path = XPath('//h:p/h:div')
|
||||||
|
path2 = XPath('//h:div[@style]/h:img[@style]')
|
||||||
for item in oeb.spine:
|
for item in oeb.spine:
|
||||||
root = item.data
|
root = item.data
|
||||||
if not hasattr(root, 'xpath'): continue
|
if not hasattr(root, 'xpath'): continue
|
||||||
for div in path(root):
|
for div in path(root):
|
||||||
div.getparent().tag = XHTML('div')
|
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']
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user