From cce2f7050797503bf2152523851930160fffabee Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 4 Jun 2015 08:18:59 +0530 Subject: [PATCH] LIT Input: Fix smarten punctuation not working for text (as opposed to HTML) based LIT files. Fixes #1460998 [Private bug](https://bugs.launchpad.net/calibre/+bug/1460998) --- src/calibre/ebooks/conversion/plugins/lit_input.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/plugins/lit_input.py b/src/calibre/ebooks/conversion/plugins/lit_input.py index e5fbdc99cb..d5643cf1a6 100644 --- a/src/calibre/ebooks/conversion/plugins/lit_input.py +++ b/src/calibre/ebooks/conversion/plugins/lit_input.py @@ -26,7 +26,8 @@ class LITInput(InputFormatPlugin): from calibre.ebooks.oeb.base import XHTML_NS, XPath, XHTML for item in oeb.spine: root = item.data - if not hasattr(root, 'xpath'): continue + if not hasattr(root, 'xpath'): + continue for bad in ('metadata', 'guide'): metadata = XPath('//h:'+bad)(root) if metadata: @@ -42,11 +43,16 @@ class LITInput(InputFormatPlugin): from calibre.ebooks.chardet import xml_to_unicode from lxml import etree import copy + self.log('LIT file with all text in singe
 tag detected')
                     html = separate_paragraphs_single_line(pre.text)
                     html = convert_basic(html).replace('',
                             ''%XHTML_NS)
                     html = xml_to_unicode(html, strip_encoding_pats=True,
                             resolve_entities=True)[0]
+                    if opts.smarten_punctuation:
+                        # SmartyPants skips text inside 
 tags
+                        from calibre.ebooks.conversion.preprocess import smarten_punctuation
+                        html = smarten_punctuation(html, self.log)
                     root = etree.fromstring(html)
                     body = XPath('//h:body')(root)
                     pre.tag = XHTML('div')