Fix usage of entitiy definitions from html5lib

This commit is contained in:
Kovid Goyal 2013-12-10 10:27:33 +05:30
parent aba91c645b
commit 4087a7004f
2 changed files with 14 additions and 2 deletions

View File

@ -562,9 +562,9 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
return check(chr(num).decode(encoding))
except UnicodeDecodeError:
return check(my_unichr(num))
from html5lib.constants import entities
from calibre.ebooks.html_entities import html5_entities
try:
return check(entities[ent])
return check(html5_entities[ent])
except KeyError:
pass
from htmlentitydefs import name2codepoint

View File

@ -0,0 +1,12 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
from html5lib.constants import entities
html5_entities = {k.replace(';', ''):v for k, v in entities.iteritems()}