diff options
author | Isaac Muse <faceless.shop@gmail.com> | 2018-01-17 18:36:34 -0700 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2018-01-17 20:36:34 -0500 |
commit | d18c3d0acab0e7469c3284c897afcb61f9dd1fea (patch) | |
tree | ce123f6ea56e105e1635126c61821d01acc82fb4 /tests/test_apis.py | |
parent | de9cc42f2d8bc29d8f16058a6ae65a434caab7d6 (diff) | |
download | python-markdown-d18c3d0acab0e7469c3284c897afcb61f9dd1fea.tar.gz |
Flexible inline (#629)
Add new InlineProcessor class that handles inline processing much better and allows for more flexibility. This adds new InlineProcessors that no longer utilize unnecessary pretext and posttext captures. New class can accept the buffer that is being worked on and manually process the text without regex and return new replacement bounds. This helps us to handle links in a better way and handle nested brackets and logic that is too much for regular expression. The refactor also allows image links to have links/paths with spaces like links. Ref #551, #613, #590, #161.
Diffstat (limited to 'tests/test_apis.py')
-rw-r--r-- | tests/test_apis.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_apis.py b/tests/test_apis.py index aa43e52..15ecc5b 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -753,16 +753,16 @@ class TestEscapeAppend(unittest.TestCase): class TestAncestorExclusion(unittest.TestCase): """ Tests exclusion of tags in ancestor list. """ - class AncestorExample(markdown.inlinepatterns.SimpleTagPattern): + class AncestorExample(markdown.inlinepatterns.SimpleTagInlineProcessor): """ Ancestor Test. """ ANCESTOR_EXCLUDES = ('a',) - def handleMatch(self, m): + def handleMatch(self, m, data): """ Handle match. """ el = markdown.util.etree.Element(self.tag) - el.text = m.group(3) - return el + el.text = m.group(2) + return el, m.start(0), m.end(0) class AncestorExtension(markdown.Extension): @@ -774,7 +774,7 @@ class TestAncestorExclusion(unittest.TestCase): def extendMarkdown(self, md, md_globals): """Modify inline patterns.""" - pattern = r'(\+)([^\+]+)\2' + pattern = r'(\+)([^\+]+)\1' md.inlinePatterns["ancestor-test"] = TestAncestorExclusion.AncestorExample(pattern, 'strong') def setUp(self): |