File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 3434 unichr = chr
3535 unicode = str
3636
37+ try :
38+ import html as HTMLLib
39+ except ImportError :
40+ HTMLLib = None
41+
3742__all__ = [
3843 'USER_AGENT' ,
3944 'DEFAULT_HEADERS' ,
@@ -121,6 +126,16 @@ def decode(html):
121126 :param str html: the HTML page or snippet to process
122127 :return str: ``html`` with all entity references replaced
123128 """
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+ try :
133+ return HTMLLib .unescape (html )
134+ except AttributeError :
135+ # Must be py3.3; fall through to our half-assed version.
136+ pass
137+
138+ # Not on py3.4+ yet? Then you get to deal with the jankiness.
124139 return r_entity .sub (entity , html )
125140
126141
You can’t perform that action at this time.
0 commit comments