File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 27
27
is_ucs4 = len (u"\U0010FFFF " ) == 1
28
28
for k , v in entities .items ():
29
29
#skip multi-character entities
30
- if ((is_ucs4 and len (v ) > 1 ) or
30
+ if ((is_ucs4 and len (v ) > 1 ) or
31
31
(not is_ucs4 and len (v ) > 2 )):
32
32
continue
33
- if v != "&" and encode_entity_map .get (v ) != k .lower ():
34
- # prefer < over < and similarly for &, >, etc.
33
+ if v != "&" :
35
34
if len (v ) == 2 :
36
35
v = utils .surrogatePairToCodepoint (v )
37
36
else :
40
39
except :
41
40
print v
42
41
raise
43
- encode_entity_map [v ] = k
42
+ if not v in encode_entity_map or k .islower ():
43
+ # prefer < over < and similarly for &, >, etc.
44
+ encode_entity_map [v ] = k
44
45
45
46
def htmlentityreplace_errors (exc ):
46
47
if isinstance (exc , (UnicodeEncodeError , UnicodeTranslateError )):
You can’t perform that action at this time.
0 commit comments