MOBI Output: Partially support CSS vertical-align length values, converting them to <sup> or <sub> tags

This commit is contained in:
Kovid Goyal 2011-02-13 18:43:05 -07:00
parent c2aa2b56bc
commit e609bd6003

View File

@ -454,8 +454,10 @@ class MobiMLizer(object):
text = COLLAPSE.sub(' ', elem.text) text = COLLAPSE.sub(' ', elem.text)
valign = style['vertical-align'] valign = style['vertical-align']
not_baseline = valign in ('super', 'sub', 'text-top', not_baseline = valign in ('super', 'sub', 'text-top',
'text-bottom') 'text-bottom') or isinstance(valign, (float, int))
vtag = 'sup' if valign in ('super', 'text-top') else 'sub' issup = valign in ('super', 'text-top') or (
isinstance(valign, (float, int)) and valign > 0)
vtag = 'sup' if issup else 'sub'
if not_baseline and not ignore_valign and tag not in NOT_VTAGS and not isblock: if not_baseline and not ignore_valign and tag not in NOT_VTAGS and not isblock:
nroot = etree.Element(XHTML('html'), nsmap=MOBI_NSMAP) nroot = etree.Element(XHTML('html'), nsmap=MOBI_NSMAP)
vbstate = BlockState(etree.SubElement(nroot, XHTML('body'))) vbstate = BlockState(etree.SubElement(nroot, XHTML('body')))