MOBI Output: When text indent is specified as a percentage in the input document, prevent the generated MOBI from having too large an indent if the user chooses a large output profile like tablet. See #1265226 (Private bug)

This commit is contained in:
Kovid Goyal 2014-01-01 09:46:46 +05:30
parent 80b0842aea
commit f092a643ae

View File

@ -346,7 +346,13 @@ class MobiMLizer(object):
if isblock: if isblock:
bstate.para = None bstate.para = None
istate.halign = style['text-align'] istate.halign = style['text-align']
rawti = style._get('text-indent')
istate.indent = style['text-indent'] istate.indent = style['text-indent']
if hasattr(rawti, 'strip') and '%' in rawti:
# We have a percentage text indent, these can come out looking
# too large if the user chooses a wide output profile like
# tablet
istate.indent = min(style._unit_convert(rawti, base=500), istate.indent)
if style['margin-left'] == 'auto' \ if style['margin-left'] == 'auto' \
and style['margin-right'] == 'auto': and style['margin-right'] == 'auto':
istate.halign = 'center' istate.halign = 'center'