mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix usage of entitiy definitions from html5lib
This commit is contained in:
parent
aba91c645b
commit
4087a7004f
@ -562,9 +562,9 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
|
|||||||
return check(chr(num).decode(encoding))
|
return check(chr(num).decode(encoding))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return check(my_unichr(num))
|
return check(my_unichr(num))
|
||||||
from html5lib.constants import entities
|
from calibre.ebooks.html_entities import html5_entities
|
||||||
try:
|
try:
|
||||||
return check(entities[ent])
|
return check(html5_entities[ent])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
from htmlentitydefs import name2codepoint
|
from htmlentitydefs import name2codepoint
|
||||||
|
12
src/calibre/ebooks/html_entities.py
Normal file
12
src/calibre/ebooks/html_entities.py
Normal 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()}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user