DOCX Output: Detect the common idiom of placing centered images as inline images inside a containing centered block and render the resulting image as a floating centered image in the DOCX file. See #1455502 (EPUB to DOCX Conversation)

This commit is contained in:
Kovid Goyal 2015-05-28 09:53:47 +05:30
parent 37eaea831b
commit 694b457a1a

View File

@ -81,6 +81,13 @@ class ImagesManager(object):
floating = 'center' if mr == 'auto' else 'right' floating = 'center' if mr == 'auto' else 'right'
if mr == 'auto': if mr == 'auto':
floating = 'center' if ml == 'auto' else 'right' floating = 'center' if ml == 'auto' else 'right'
else:
parent = html_img.getparent()
if len(parent) == 1 and not (parent.text or '').strip() and not (html_img.tail or '').strip():
# We have an inline image alone inside a block
pstyle = stylizer.style(parent)
if pstyle['text-align'] in ('center', 'right'):
floating = pstyle['text-align']
fake_margins = floating is None fake_margins = floating is None
self.count += 1 self.count += 1
img = self.images[href] img = self.images[href]