Minor improvement for --parse-errors

This commit is contained in:
Miroslav Stampar
2019-05-28 23:44:27 +02:00
parent 8ca4cffb98
commit 00435934bc
3 changed files with 11 additions and 5 deletions

View File

@@ -80,15 +80,17 @@ def htmlUnescape(value):
"""
retVal = value
if value and isinstance(value, six.string_types):
replacements = (("&lt;", '<'), ("&gt;", '>'), ("&quot;", '"'), ("&nbsp;", ' '), ("&amp;", '&'), ("&apos;", "'"))
for code, value in replacements:
retVal = retVal.replace(code, value)
try:
retVal = re.sub(r"&#x([^ ;]+);", lambda match: _unichr(int(match.group(1), 16)), retVal)
retVal = getText(re.sub(r"&#x([^ ;]+);", lambda match: _unichr(int(match.group(1), 16)), retVal))
except ValueError:
pass
return retVal
def singleTimeWarnMessage(message): # Cross-referenced function