From eea893682228299b9d90c69f52eb9075612d8708 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sat, 17 Mar 2018 17:52:17 +0100 Subject: [PATCH] Unescape all HTML entities prior to parsing. --- matrix/colors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/matrix/colors.py b/matrix/colors.py index 0c080ff..247c8f0 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -32,6 +32,8 @@ try: except ImportError: from html.parser import HTMLParser +from html.entities import name2codepoint + FormattedString = namedtuple('FormattedString', ['text', 'attributes']) quote_wrapper = textwrap.TextWrapper( @@ -314,6 +316,10 @@ class MatrixHtmlParser(HTMLParser): self.substrings = [] # type: List[FormattedString] self.attributes = DEFAULT_ATRIBUTES.copy() + def feed(self, text): + text = self.unescape(text) + return HTMLParser.feed(self, text) + def _toggle_attribute(self, attribute): if self.text: self.substrings.append(