SMarten punctuation: Handle non breaking spaces used as indents when converting opening quotes

This commit is contained in:
Kovid Goyal 2011-02-15 20:00:43 -07:00
commit 438d294f0b

View File

@ -568,11 +568,14 @@ class HTMLPreProcessor(object):
def smarten_punctuation(self, html): def smarten_punctuation(self, html):
from calibre.utils.smartypants import smartyPants from calibre.utils.smartypants import smartyPants
from calibre.ebooks.chardet import substitute_entites from calibre.ebooks.chardet import substitute_entites
from calibre.ebooks.conversion.utils import HeuristicProcessor
preprocessor = HeuristicProcessor(self.extra_opts, self.log)
from uuid import uuid4 from uuid import uuid4
start = 'calibre-smartypants-'+str(uuid4()) start = 'calibre-smartypants-'+str(uuid4())
stop = 'calibre-smartypants-'+str(uuid4()) stop = 'calibre-smartypants-'+str(uuid4())
html = html.replace('<!--', start) html = html.replace('<!--', start)
html = html.replace('-->', stop) html = html.replace('-->', stop)
html = preprocessor.fix_nbsp_indents(html)
html = smartyPants(html) html = smartyPants(html)
html = html.replace(start, '<!--') html = html.replace(start, '<!--')
html = html.replace(stop, '-->') html = html.replace(stop, '-->')