summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-10-22 16:53:26 -0500
committerptmcg <ptmcg@austin.rr.com>2021-10-22 16:53:26 -0500
commitaab37b6838b2f5be43c137ca17a40d5f22d3279f (patch)
treec30d4bd0b9b5c66d93f380c1fdfa55791e66738b /tests
parent69b6c5a6a1a6890bbe99c1fb47813467d4f118aa (diff)
downloadpyparsing-git-aab37b6838b2f5be43c137ca17a40d5f22d3279f.tar.gz
Modified helpers common_html_entity and replace_html_entity() to use the HTML entity definitions from html.entities.html5
Diffstat (limited to 'tests')
-rw-r--r--tests/test_unit.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py
index ca9b474..110fed8 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -1860,6 +1860,31 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
self.assertParseResultsEquals(testVal, expected_list=expected)
+ def testHTMLEntities(self):
+ html_source = dedent("""\
+ This &amp; that
+ 2 &gt; 1
+ 0 &lt; 1
+ Don&apos;t get excited!
+ I said &quot;Don&apos;t get excited!&quot;
+ Copyright &copy; 2021
+ Dot &longrightarrow; &dot;
+ """)
+ transformer = pp.common_html_entity.add_parse_action(pp.replace_html_entity)
+ transformed = transformer.transform_string(html_source)
+ print(transformed)
+
+ expected = dedent("""\
+ This & that
+ 2 > 1
+ 0 < 1
+ Don't get excited!
+ I said "Don't get excited!"
+ Copyright © 2021
+ Dot ⟶ ˙
+ """)
+ self.assertEqual(expected, transformed)
+
def testInfixNotationBasicArithEval(self):
import ast