summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2013-09-21 05:24:32 +0800
committerYu-Jie Lin <livibetter@gmail.com>2013-09-21 05:24:32 +0800
commit1daf463ae09e3db7cb960775087f21ff5ce25dc6 (patch)
tree99188b7d824e2eff51c3239e17ed9fe045b1409a /tests
parenta3847b49f3d031a354e09f976ff1b541088946f3 (diff)
downloadsmartypants-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.py36
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("--"), "&#8212;")
self.assertEqual(sp("-->"), "&#8212;>")
- self.assertEqual(sp("<!-- comment -->"), "<!-- comment -->")
- self.assertEqual(sp("<!-- <li>Fee-fi-of-fum</li> -->"),
- "<!-- <li>Fee-fi-of-fum</li> -->")
+ self.assertEqual(sp("-- \t >"), "&#8212; \t >")
+
+ TEXT = '<!-- "foo" --> blah--blah <!-- "bar" -->'
+ T = sp(TEXT)
+ E = '<!-- "foo" --> blah&#8212;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 &#8212; &#8220;bar&#8221;<!-- 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('<!-- -- -->'), '<!&#8212; &#8212; &#8212;>')
+ self.assertEqual(sp('<!-- -- -- \t >'),
+ '<!&#8212; &#8212; &#8212; \t >')
def test_ordinal_numbers(self):