Fix charrefs.
Forgot to include # when reconstructing charrefs from their "name".
This commit is contained in:
parent
6eec395254
commit
6e9275da7f
2 changed files with 19 additions and 1 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,6 +33,24 @@ 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>')
|
||||||
|
|
Loading…
Reference in a new issue