From 9889b5fc7d9cb5c2522812d1a6de7ea691c14556 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Aug 2017 15:07:06 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/oeb/stylizer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index c791b093d0..68ada13229 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -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