re-worked unsupported unicode chars Output profile option to use Unidecoder to do simple ascii conversion

This commit is contained in:
ldolse 2010-09-27 19:13:57 +08:00
parent 217a1716fa
commit 2f04d0b17c
2 changed files with 7 additions and 3 deletions

View File

@ -426,7 +426,7 @@ class SonyReaderOutput(OutputProfile):
dpi = 168.451 dpi = 168.451
fbase = 12 fbase = 12
fsizes = [7.5, 9, 10, 12, 15.5, 20, 22, 24] fsizes = [7.5, 9, 10, 12, 15.5, 20, 22, 24]
unsupported_unicode_chars = [[u'\u2018',u''], [u'\u2019',u''], [u'\u201a',u''], [u'\u201b',u''], [u'\u201c',u''], [u'\u201d',u''], [u'\u201e',u''], [u'\u201f',u'']] unsupported_unicode_chars = [u'\u201f', u'\u201b']
class KoboReaderOutput(OutputProfile): class KoboReaderOutput(OutputProfile):

View File

@ -520,8 +520,12 @@ class HTMLPreProcessor(object):
html = self.smarten_punctuation(html) html = self.smarten_punctuation(html)
unsupported_unicode_chars = self.extra_opts.output_profile.unsupported_unicode_chars unsupported_unicode_chars = self.extra_opts.output_profile.unsupported_unicode_chars
for [char, replacement] in unsupported_unicode_chars: if unsupported_unicode_chars != []:
html = re.sub('%s' % char, replacement, html) from calibre.ebooks.unidecode.unidecoder import Unidecoder
unidecoder = Unidecoder()
for char in unsupported_unicode_chars:
asciichar = unidecoder.decode(char)
html = re.sub('%s' % char, asciichar, html)
return html return html