mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
8fcaf05e98
commit
9889b5fc7d
@ -237,8 +237,6 @@ class Stylizer(object):
|
|||||||
if fl == 'first-letter' and getattr(self.oeb,
|
if fl == 'first-letter' and getattr(self.oeb,
|
||||||
'plumber_output_format', '').lower() in {u'mobi', u'docx'}:
|
'plumber_output_format', '').lower() in {u'mobi', u'docx'}:
|
||||||
# Fake first-letter
|
# Fake first-letter
|
||||||
from lxml.builder import ElementMaker
|
|
||||||
E = ElementMaker(namespace=XHTML_NS)
|
|
||||||
for elem in matches:
|
for elem in matches:
|
||||||
for x in elem.iter('*'):
|
for x in elem.iter('*'):
|
||||||
if x.text:
|
if x.text:
|
||||||
@ -253,7 +251,8 @@ class Stylizer(object):
|
|||||||
|
|
||||||
special_text = u''.join(punctuation_chars) + \
|
special_text = u''.join(punctuation_chars) + \
|
||||||
(text[0] if text else u'')
|
(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.set('data-fake-first-letter', '1')
|
||||||
span.tail = text[1:]
|
span.tail = text[1:]
|
||||||
x.text = None
|
x.text = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user