mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI Output: Fix underline and strikethrough properties declared on parents not being rendered on child tags. Fixes #894245 (Private bug)
This commit is contained in:
parent
c512404062
commit
5640d4a45d
@ -376,8 +376,8 @@ class MobiMLizer(object):
|
||||
istate.preserve = (style['white-space'] in ('pre', 'pre-wrap'))
|
||||
istate.bgcolor = style['background-color']
|
||||
istate.fgcolor = style['color']
|
||||
istate.strikethrough = style['text-decoration'] == 'line-through'
|
||||
istate.underline = style['text-decoration'] == 'underline'
|
||||
istate.strikethrough = style.effective_text_decoration == 'line-through'
|
||||
istate.underline = style.effective_text_decoration == 'underline'
|
||||
ff = style['font-family'].lower() if style['font-family'] else ''
|
||||
if 'monospace' in ff or 'courier' in ff or ff.endswith(' mono'):
|
||||
istate.family = 'monospace'
|
||||
|
@ -714,6 +714,26 @@ class Style(object):
|
||||
self._lineHeight = result
|
||||
return self._lineHeight
|
||||
|
||||
@property
|
||||
def effective_text_decoration(self):
|
||||
'''
|
||||
Browsers do this creepy thing with text-decoration where even though the
|
||||
property is not inherited, it looks like it is because containing
|
||||
blocks apply it. The actual algorithm is utterly ridiculous, see
|
||||
http://reference.sitepoint.com/css/text-decoration
|
||||
This matters for MOBI output, where text-decoration is mapped to <u>
|
||||
and <st> tags. Trying to implement the actual algorithm is too much
|
||||
work, so we just use a simple fake that should cover most cases.
|
||||
'''
|
||||
css = self._style.get('text-decoration', None)
|
||||
pcss = None
|
||||
parent = self._get_parent()
|
||||
if parent is not None:
|
||||
pcss = parent._style.get('text-decoration', None)
|
||||
if css in ('none', None) and pcss not in (None, 'none'):
|
||||
return pcss
|
||||
return css
|
||||
|
||||
@property
|
||||
def marginTop(self):
|
||||
return self._unit_convert(
|
||||
|
Loading…
x
Reference in New Issue
Block a user