diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index fdfb91d7bb..917df54f6b 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -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 diff --git a/src/calibre/ebooks/html_entities.py b/src/calibre/ebooks/html_entities.py new file mode 100644 index 0000000000..aba8ba80e1 --- /dev/null +++ b/src/calibre/ebooks/html_entities.py @@ -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 ' + +from html5lib.constants import entities + +html5_entities = {k.replace(';', ''):v for k, v in entities.iteritems()} +