diff options
author | Yu-Jie Lin <livibetter@gmail.com> | 2013-09-21 05:24:32 +0800 |
---|---|---|
committer | Yu-Jie Lin <livibetter@gmail.com> | 2013-09-21 05:24:32 +0800 |
commit | 1daf463ae09e3db7cb960775087f21ff5ce25dc6 (patch) | |
tree | 99188b7d824e2eff51c3239e17ed9fe045b1409a /tests | |
parent | a3847b49f3d031a354e09f976ff1b541088946f3 (diff) | |
download | smartypants-1daf463ae09e3db7cb960775087f21ff5ce25dc6.tar.gz |
fix hyphens do not cause a comment not a comment, add more tests
In both HTML4 and HTML5, two hyphens should not (HTML4) or must not (HTML5) be contained in comments. This would make sure if they appear in a comment, then the entire comment will be treated as text, which means it will be converted.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.py | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/test.py b/tests/test.py index 85e8af2..6b2c5da 100644 --- a/tests/test.py +++ b/tests/test.py @@ -88,9 +88,39 @@ document.write('<a href="' + href + '">' + linktext + "</a>"); self.assertEqual(sp("--"), "—") self.assertEqual(sp("-->"), "—>") - self.assertEqual(sp("<!-- comment -->"), "<!-- comment -->") - self.assertEqual(sp("<!-- <li>Fee-fi-of-fum</li> -->"), - "<!-- <li>Fee-fi-of-fum</li> -->") + self.assertEqual(sp("-- \t >"), "— \t >") + + TEXT = '<!-- "foo" --> blah--blah <!-- "bar" -->' + T = sp(TEXT) + E = '<!-- "foo" --> blah—blah <!-- "bar" -->' + self.assertEqual(T, E) + + TEXT = ( + '<p>foo -- "bar"<!-- foo-bar\n' + '<p>blah "this"</p>\n' + '-->\n' + '</p>' + ) + + T = sp(TEXT) + E = ( + '<p>foo — “bar”<!-- foo-bar\n' + '<p>blah "this"</p>\n' + '-->\n' + '</p>' + ) + self.assertEqual(T, E) + + # nothing should be converted + for TEXT in ('<!-- comment -->', + '<!-- <li>Fee-fi-of-fum</li> -->', + '<!-- "foo" --> <!-- "bar" -->'): + self.assertEqual(sp(TEXT), TEXT) + + # not comments + self.assertEqual(sp('<!-- -- -->'), '<!— — —>') + self.assertEqual(sp('<!-- -- -- \t >'), + '<!— — — \t >') def test_ordinal_numbers(self): |