Conversion pipeline: Add support for all the named entities in the HTML 5 spec. Fixes #976056 (A couple HTML entity codes for fractions not converted)

This commit is contained in:
Kovid Goyal 2012-04-08 21:45:38 +05:30
parent b9be0e215c
commit 1a5be5a398
2 changed files with 2131 additions and 1 deletions

View File

@ -5,7 +5,6 @@ __docformat__ = 'restructuredtext en'
import sys, os, re, time, random, __builtin__, warnings
__builtin__.__dict__['dynamic_property'] = lambda(func): func(None)
from htmlentitydefs import name2codepoint
from math import floor
from functools import partial
@ -551,6 +550,12 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
return check(chr(num).decode(encoding))
except UnicodeDecodeError:
return check(my_unichr(num))
from calibre.utils.html5_entities import entity_map
try:
return check(entity_map[ent])
except KeyError:
pass
from htmlentitydefs import name2codepoint
try:
return check(my_unichr(name2codepoint[ent]))
except KeyError:

File diff suppressed because it is too large Load Diff