diff options
author | ysard <ysard@users.noreply.github.com> | 2022-05-05 21:47:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 15:47:59 -0400 |
commit | efec51ac92059fc5b72f08832b481919a3ded6f3 (patch) | |
tree | c46d951ec56c7c0b3e6fea328e5f2cadfa7e4a8c /tests/test_syntax/extensions/test_footnotes.py | |
parent | 0f5f8af08b415af7647cbc484f0408695e019d3a (diff) | |
download | python-markdown-efec51ac92059fc5b72f08832b481919a3ded6f3.tar.gz |
Footnotes improvements
* footnotes: Allow to use backlink title without footnote number
- The placeholder '{}' is optional. So a user can choose to include or
not the footnote number in the backlink text.
- The modification is backward compatible with configurations using
the old '%d' placeholder.
* footnotes: Allow to use custom superscript text
- The addition of a new SUPERSCRIPT_TEXT option allows to specify
a placeholder receiving the footnote number for the superscript text.
Diffstat (limited to 'tests/test_syntax/extensions/test_footnotes.py')
-rw-r--r-- | tests/test_syntax/extensions/test_footnotes.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_syntax/extensions/test_footnotes.py b/tests/test_syntax/extensions/test_footnotes.py index 1a3a2b0..9a6b32a 100644 --- a/tests/test_syntax/extensions/test_footnotes.py +++ b/tests/test_syntax/extensions/test_footnotes.py @@ -300,3 +300,39 @@ class TestFootnotes(TestCase): '</div>', extension_configs={'footnotes': {'SEPARATOR': '-'}} ) + + def test_backlink_title(self): + """Test backlink title configuration without placeholder.""" + + self.assertMarkdownRenders( + 'paragraph[^1]\n\n[^1]: A Footnote', + '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n' + '<div class="footnote">\n' + '<hr />\n' + '<ol>\n' + '<li id="fn:1">\n' + '<p>A Footnote <a class="footnote-backref" href="#fnref:1"' + ' title="Jump back to footnote">↩</a></p>\n' + '</li>\n' + '</ol>\n' + '</div>', + extension_configs={'footnotes': {'BACKLINK_TITLE': 'Jump back to footnote'}} + ) + + def test_superscript_text(self): + """Test superscript text configuration.""" + + self.assertMarkdownRenders( + 'paragraph[^1]\n\n[^1]: A Footnote', + '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">[1]</a></sup></p>\n' + '<div class="footnote">\n' + '<hr />\n' + '<ol>\n' + '<li id="fn:1">\n' + '<p>A Footnote <a class="footnote-backref" href="#fnref:1"' + ' title="Jump back to footnote 1 in the text">↩</a></p>\n' + '</li>\n' + '</ol>\n' + '</div>', + extension_configs={'footnotes': {'SUPERSCRIPT_TEXT': '[{}]'}} + ) |