summaryrefslogtreecommitdiff
path: root/tests/test_syntax/inline
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2022-11-14 14:26:27 -0500
committerWaylan Limberg <waylan.limberg@icloud.com>2022-11-15 11:55:37 -0500
commit939a2fe70580c8e6b7e10af82ebdd6c8c72e019a (patch)
treece92d886eac0f519ba8418d93071167f44a5605b /tests/test_syntax/inline
parente97ffebc9d22f6dc84087caaf11978d4548c617c (diff)
downloadpython-markdown-939a2fe70580c8e6b7e10af82ebdd6c8c72e019a.tar.gz
Improve standalone * and _ parsing.
The `NOT_STRONG_RE` regex matchs 1, 2, or 3 * or _ which are surrounded by white space to prevent them from being parsed as tokens. However, the surrounding white space should not be consumed by the regex, which is why lookhead and lookbehind assertions are used. As `^` cannot be matched in a lookbehind assertion, it is left outside the assertion, but as it is zero length, that should not matter. Tests added and/or updated to cover various edge cases. Fixes #1300.
Diffstat (limited to 'tests/test_syntax/inline')
-rw-r--r--tests/test_syntax/inline/test_emphasis.py48
1 files changed, 45 insertions, 3 deletions
diff --git a/tests/test_syntax/inline/test_emphasis.py b/tests/test_syntax/inline/test_emphasis.py
index 1e7fafa..29107c7 100644
--- a/tests/test_syntax/inline/test_emphasis.py
+++ b/tests/test_syntax/inline/test_emphasis.py
@@ -36,6 +36,42 @@ class TestNotEmphasis(TestCase):
'<p>_</p>'
)
+ def test_standalone_asterisks_consecutive(self):
+ self.assertMarkdownRenders(
+ 'Foo * * * *',
+ '<p>Foo * * * *</p>'
+ )
+
+ def test_standalone_understore_consecutive(self):
+ self.assertMarkdownRenders(
+ 'Foo _ _ _ _',
+ '<p>Foo _ _ _ _</p>'
+ )
+
+ def test_standalone_asterisks_pairs(self):
+ self.assertMarkdownRenders(
+ 'Foo ** ** ** **',
+ '<p>Foo ** ** ** **</p>'
+ )
+
+ def test_standalone_understore_pairs(self):
+ self.assertMarkdownRenders(
+ 'Foo __ __ __ __',
+ '<p>Foo __ __ __ __</p>'
+ )
+
+ def test_standalone_asterisks_triples(self):
+ self.assertMarkdownRenders(
+ 'Foo *** *** *** ***',
+ '<p>Foo *** *** *** ***</p>'
+ )
+
+ def test_standalone_understore_triples(self):
+ self.assertMarkdownRenders(
+ 'Foo ___ ___ ___ ___',
+ '<p>Foo ___ ___ ___ ___</p>'
+ )
+
def test_standalone_asterisk_in_text(self):
self.assertMarkdownRenders(
'foo * bar',
@@ -72,10 +108,16 @@ class TestNotEmphasis(TestCase):
'<p>foo\n_ bar _\nbaz</p>'
)
- def test_standalone_asterisks_at_end(self):
+ def test_standalone_underscore_at_begin(self):
+ self.assertMarkdownRenders(
+ '_ foo_ bar',
+ '<p>_ foo_ bar</p>'
+ )
+
+ def test_standalone_asterisk_at_end(self):
self.assertMarkdownRenders(
- 'foo * bar *',
- '<p>foo * bar *</p>'
+ 'foo *bar *',
+ '<p>foo *bar *</p>'
)
def test_standalone_understores_at_begin_end(self):