mirror of
https://github.com/python/cpython.git
synced 2025-11-06 08:31:58 +00:00
revert creation of the html.entities and html.parser modules
(http://bugs.python.org/issue2882)
This commit is contained in:
parent
1f60af87f5
commit
d995e1150c
15 changed files with 722 additions and 90 deletions
|
|
@ -372,17 +372,16 @@ def replaceEntities(s):
|
|||
c = int(s)
|
||||
return unichr(c)
|
||||
else:
|
||||
# Cannot use name2codepoint directly, because HTMLParser
|
||||
# supports apos, which is not part of HTML 4
|
||||
import html.entities
|
||||
# Cannot use name2codepoint directly, because HTMLParser supports apos,
|
||||
# which is not part of HTML 4
|
||||
import htmlentitydefs
|
||||
if HTMLParser.entitydefs is None:
|
||||
entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
|
||||
for k, v in html.entities.name2codepoint.iteritems():
|
||||
for k, v in htmlentitydefs.name2codepoint.iteritems():
|
||||
entitydefs[k] = unichr(v)
|
||||
try:
|
||||
return self.entitydefs[s]
|
||||
except KeyError:
|
||||
return '&'+s+';'
|
||||
|
||||
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));",
|
||||
replaceEntities, s)
|
||||
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue