We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ad96596 commit bc4cecaCopy full SHA for bc4ceca
html5lib/serializer/htmlserializer.py
@@ -27,11 +27,10 @@
27
is_ucs4 = len(u"\U0010FFFF") == 1
28
for k, v in entities.items():
29
#skip multi-character entities
30
- if ((is_ucs4 and len(v) > 1) or
+ if ((is_ucs4 and len(v) > 1) or
31
(not is_ucs4 and len(v) > 2)):
32
continue
33
- if v != "&" and encode_entity_map.get(v) != k.lower():
34
- # prefer < over < and similarly for &, >, etc.
+ if v != "&":
35
if len(v) == 2:
36
v = utils.surrogatePairToCodepoint(v)
37
else:
@@ -40,7 +39,9 @@
40
39
except:
41
print v
42
raise
43
- encode_entity_map[v] = k
+ if not v in encode_entity_map or k.islower():
+ # prefer < over < and similarly for &, >, etc.
44
+ encode_entity_map[v] = k
45
46
def htmlentityreplace_errors(exc):
47
if isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError)):
0 commit comments