mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
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:
parent
37eaea831b
commit
694b457a1a
@ -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]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user