Fix a regression that could cause conversion to crash when using the first-letter CSS pseudo selector and outputting to MOBI or DOCX. Fixes #1711224 [Calibre 3.6 crashes while fetching news](https://bugs.launchpad.net/calibre/+bug/1711224)

This commit is contained in:
Kovid Goyal 2017-08-18 15:07:06 +05:30
parent 8fcaf05e98
commit 9889b5fc7d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -237,8 +237,6 @@ class Stylizer(object):
if fl == 'first-letter' and getattr(self.oeb,
'plumber_output_format', '').lower() in {u'mobi', u'docx'}:
# Fake first-letter
from lxml.builder import ElementMaker
E = ElementMaker(namespace=XHTML_NS)
for elem in matches:
for x in elem.iter('*'):
if x.text:
@ -253,7 +251,8 @@ class Stylizer(object):
special_text = u''.join(punctuation_chars) + \
(text[0] if text else u'')
span = E.span(special_text)
span = x.makeelement('{%s}span' % XHTML_NS)
span.text = special_text
span.set('data-fake-first-letter', '1')
span.tail = text[1:]
x.text = None