mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
b9be0e215c
commit
1a5be5a398
@ -5,7 +5,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import sys, os, re, time, random, __builtin__, warnings
|
import sys, os, re, time, random, __builtin__, warnings
|
||||||
__builtin__.__dict__['dynamic_property'] = lambda(func): func(None)
|
__builtin__.__dict__['dynamic_property'] = lambda(func): func(None)
|
||||||
from htmlentitydefs import name2codepoint
|
|
||||||
from math import floor
|
from math import floor
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
@ -551,6 +550,12 @@ 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 calibre.utils.html5_entities import entity_map
|
||||||
|
try:
|
||||||
|
return check(entity_map[ent])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
from htmlentitydefs import name2codepoint
|
||||||
try:
|
try:
|
||||||
return check(my_unichr(name2codepoint[ent]))
|
return check(my_unichr(name2codepoint[ent]))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
2125
src/calibre/utils/html5_entities.py
Normal file
2125
src/calibre/utils/html5_entities.py
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user