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.
html.unescape()
1 parent e655564 commit 602f028Copy full SHA for 602f028
sopel/tools/web.py
@@ -34,6 +34,11 @@
34
unichr = chr
35
unicode = str
36
37
+try:
38
+ import html as HTMLLib
39
+except ImportError:
40
+ HTMLLib = None
41
+
42
__all__ = [
43
'USER_AGENT',
44
'DEFAULT_HEADERS',
@@ -121,6 +126,12 @@ def decode(html):
121
126
:param str html: the HTML page or snippet to process
122
127
:return str: ``html`` with all entity references replaced
123
128
"""
129
+ if HTMLLib is not None:
130
+ # Python's stdlib has our back in 3.4+
131
+ # TODO: This should be the only implementation in Sopel 8
132
+ return HTMLLib.unescape(html)
133
134
+ # Not on py3.4+ yet? Then you get to deal with the jankiness.
124
135
return r_entity.sub(entity, html)
125
136
137
0 commit comments