diff options
| author | Waylan Limberg <waylan.limberg@icloud.com> | 2020-06-25 15:34:51 -0400 |
|---|---|---|
| committer | Waylan Limberg <waylan.limberg@icloud.com> | 2020-06-30 14:36:01 -0400 |
| commit | 706d1fd096a49df0662a181f9dae726edefff43f (patch) | |
| tree | c69d4d8500cc171118eda319a748ce498c439dd6 /tests/test_syntax | |
| parent | 071c4f1420ac3c80ad621522b9996bcc1cd94bcf (diff) | |
| download | python-markdown-706d1fd096a49df0662a181f9dae726edefff43f.tar.gz | |
Tune attr list regex
Ignore empty braces. Braces must contain at least one non-whitepsace
character to be recognized as an attr list.
Attr lists for table cells must be at the end of the cell content and must
be seperated from the content by at least one space. This appears to be
a breaking change. However, it is consistent with the behavior elsewhere.
Fixes #898.
Diffstat (limited to 'tests/test_syntax')
| -rw-r--r-- | tests/test_syntax/extensions/test_attr_list.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/test_syntax/extensions/test_attr_list.py b/tests/test_syntax/extensions/test_attr_list.py new file mode 100644 index 0000000..3d65761 --- /dev/null +++ b/tests/test_syntax/extensions/test_attr_list.py @@ -0,0 +1,72 @@ +""" +Python Markdown + +A Python implementation of John Gruber's Markdown. + +Documentation: https://python-markdown.github.io/ +GitHub: https://github.com/Python-Markdown/markdown/ +PyPI: https://pypi.org/project/Markdown/ + +Started by Manfred Stienstra (http://www.dwerg.net/). +Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org). +Currently maintained by Waylan Limberg (https://github.com/waylan), +Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser). + +Copyright 2007-2020 The Python Markdown Project (v. 1.7 and later) +Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b) +Copyright 2004 Manfred Stienstra (the original version) + +License: BSD (see LICENSE.md for details). +""" + +from markdown.test_tools import TestCase + + +class TestAttrList(TestCase): + + maxDiff = None + + # TODO: Move the rest of the attr_list tests here. + + def test_empty_list(self): + self.assertMarkdownRenders( + '*foo*{ }', + '<p><em>foo</em>{ }</p>', + extensions=['attr_list'] + ) + + def test_table_td(self): + self.assertMarkdownRenders( + self.dedent( + """ + | valid on td | inline | empty | missing space | not at end | + |-------------|-------------|-------|---------------|--------------| + | a { .foo } | *b*{ .foo } | c { } | d{ .foo } | e { .foo } f | + """ + ), + self.dedent( + """ + <table> + <thead> + <tr> + <th>valid on td</th> + <th>inline</th> + <th>empty</th> + <th>missing space</th> + <th>not at end</th> + </tr> + </thead> + <tbody> + <tr> + <td class="foo">a</td> + <td><em class="foo">b</em></td> + <td>c { }</td> + <td>d{ .foo }</td> + <td>e { .foo } f</td> + </tr> + </tbody> + </table> + """ + ), + extensions=['attr_list', 'tables'] + ) |
