commit
508a80e981
2 changed files with 19 additions and 2 deletions
|
@ -404,7 +404,7 @@ class MatrixHtmlParser(HTMLParser):
|
||||||
self.text += self.unescape("&{};".format(name))
|
self.text += self.unescape("&{};".format(name))
|
||||||
|
|
||||||
def handle_charref(self, name):
|
def handle_charref(self, name):
|
||||||
self.text += self.unescape("&{};".format(name))
|
self.text += self.unescape("&#{};".format(name))
|
||||||
|
|
||||||
def get_substrings(self):
|
def get_substrings(self):
|
||||||
if self.text:
|
if self.text:
|
||||||
|
|
|
@ -33,9 +33,26 @@ def test_html_numeric_reference_parsing(entitydef):
|
||||||
assert parser.unescape('&#{};'.format(num)) == character
|
assert parser.unescape('&#{};'.format(num)) == character
|
||||||
|
|
||||||
|
|
||||||
|
@given(sampled_from(html_entities))
|
||||||
|
def test_html_entityref_reconstruction_from_name(entitydef):
|
||||||
|
name = entitydef[0]
|
||||||
|
parser = MatrixHtmlParser()
|
||||||
|
parser.handle_entityref(name)
|
||||||
|
s = parser.get_substrings()
|
||||||
|
assert s[0].text == parser.unescape('&{};'.format(name)) and len(s) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@given(sampled_from(html_entities))
|
||||||
|
def test_html_charref_reconstruction_from_name(entitydef):
|
||||||
|
num = entitydef[2]
|
||||||
|
parser = MatrixHtmlParser()
|
||||||
|
parser.handle_charref(num)
|
||||||
|
s = parser.get_substrings()
|
||||||
|
assert s[0].text == parser.unescape('&#{};'.format(num)) and len(s) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_parsing_of_escaped_brackets():
|
def test_parsing_of_escaped_brackets():
|
||||||
p = MatrixHtmlParser()
|
p = MatrixHtmlParser()
|
||||||
p.feed('<pre><code><faketag></code></pre>')
|
p.feed('<pre><code><faketag></code></pre>')
|
||||||
s = p.get_substrings()
|
s = p.get_substrings()
|
||||||
print(s)
|
|
||||||
assert s[0].text == '<faketag>' and len(s) == 1
|
assert s[0].text == '<faketag>' and len(s) == 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue