diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2021-02-24 14:20:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 14:20:29 -0500 |
commit | 613ad502a4cf2293901e8f67690c198fc22c8f88 (patch) | |
tree | 881dcb80d9a2ba31f6e7e72cccb932c05fc25d6f | |
parent | 1858c1b601ead62ed49646ae0d99298f41b1a271 (diff) | |
download | python-markdown-613ad502a4cf2293901e8f67690c198fc22c8f88.tar.gz |
Ensure permalinks and ankorlinks are not restricted by toc_depth
This fixes a regression which was introduced with support for toc_depth.
Relevant tests have been moved and updated to the new framework.
Fixes #1107.
The test framework also received an addition. The assertMarkdownRenders
method now accepts a new keyword expected_attrs which consists of a dict
of attrs and expected values. Each is checked against the attr of the
Markdown instance. This was needed to check the value of md.toc and
md.toc_tokens in some of the included tests.
-rw-r--r-- | docs/change_log/index.md | 1 | ||||
-rw-r--r-- | docs/test_tools.md | 16 | ||||
-rw-r--r-- | markdown/extensions/toc.py | 19 | ||||
-rw-r--r-- | markdown/test_tools.py | 16 | ||||
-rw-r--r-- | tests/test_extensions.py | 193 | ||||
-rw-r--r-- | tests/test_syntax/extensions/test_toc.py | 398 |
6 files changed, 426 insertions, 217 deletions
diff --git a/docs/change_log/index.md b/docs/change_log/index.md index b9a1a90..2b550e4 100644 --- a/docs/change_log/index.md +++ b/docs/change_log/index.md @@ -10,6 +10,7 @@ Under development: version 3.3.4 (a bug-fix release). * Properly parse code spans in md_in_html (#1069). * Preserve text immediately before an admonition (#1092). * Simplified regex for HTML placeholders (#928) addressing (#932). +* Ensure `permalinks` and `ankorlinks` are not restricted by `toc_depth` (#1107). Oct 25, 2020: version 3.3.3 (a bug-fix release). diff --git a/docs/test_tools.md b/docs/test_tools.md index 3a83d8e..f3ed4e5 100644 --- a/docs/test_tools.md +++ b/docs/test_tools.md @@ -22,12 +22,16 @@ Properties test. The defaults can be overridden on individual tests. Methods -: `assertMarkdownRenders`: accepts the source text, the expected output, - and any keywords to pass to Markdown. The `default_kwargs` defined on the - class are used except where overridden by keyword arguments. The output and - expected output are passed to `TestCase.assertMultiLineEqual`. An - `AssertionError` is raised with a diff if the actual output does not equal the - expected output. +: `assertMarkdownRenders`: accepts the source text, the expected output, an optional + dictionary of `expected_attrs`, and any keywords to pass to Markdown. The + `default_kwargs` defined on the class are used except where overridden by + keyword arguments. The output and expected output are passed to + `TestCase.assertMultiLineEqual`. An `AssertionError` is raised with a diff + if the actual output does not equal the expected output. The optional + keyword `expected_attrs` accepts a dictionary of attribute names as keys with + expected values. Each value is checked against the attribute of that + name on the instance of the `Markdown` class using `TestCase.assertEqual`. An + `AssertionError` is raised if any value does not match the expected value. : `dedent`: Dedent triple-quoted strings. diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index b2564c9..d64ec16 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -269,8 +269,6 @@ class TocTreeprocessor(Treeprocessor): for el in doc.iter(): if isinstance(el.tag, str) and self.header_rgx.match(el.tag): self.set_level(el) - if int(el.tag[-1]) < self.toc_top or int(el.tag[-1]) > self.toc_bottom: - continue text = get_name(el) # Do not override pre-existing ids @@ -278,14 +276,15 @@ class TocTreeprocessor(Treeprocessor): innertext = unescape(stashedHTML2text(text, self.md)) el.attrib["id"] = unique(self.slugify(innertext, self.sep), used_ids) - toc_tokens.append({ - 'level': int(el.tag[-1]), - 'id': el.attrib["id"], - 'name': unescape(stashedHTML2text( - code_escape(el.attrib.get('data-toc-label', text)), - self.md, strip_entities=False - )) - }) + if int(el.tag[-1]) >= self.toc_top and int(el.tag[-1]) <= self.toc_bottom: + toc_tokens.append({ + 'level': int(el.tag[-1]), + 'id': el.attrib["id"], + 'name': unescape(stashedHTML2text( + code_escape(el.attrib.get('data-toc-label', text)), + self.md, strip_entities=False + )) + }) # Remove the data-toc-label attribute as it is no longer needed if 'data-toc-label' in el.attrib: diff --git a/markdown/test_tools.py b/markdown/test_tools.py index 5f33619..21ae1a7 100644 --- a/markdown/test_tools.py +++ b/markdown/test_tools.py @@ -23,7 +23,7 @@ import os import sys import unittest import textwrap -from . import markdown, util +from . import markdown, Markdown, util try: import tidylib @@ -54,15 +54,25 @@ class TestCase(unittest.TestCase): default_kwargs = {} - def assertMarkdownRenders(self, source, expected, **kwargs): + def assertMarkdownRenders(self, source, expected, expected_attrs=None, **kwargs): """ Test that source Markdown text renders to expected output with given keywords. + + `expected_attrs` accepts a dict. Each key should be the name of an attribute + on the `Markdown` instance and the value should be the expected value after + the source text is parsed by Markdown. After the expected output is tested, + the expected value for each attribute is compared against the actual + attribute of the `Markdown` instance using `TestCase.assertEqual`. """ + expected_attrs = expected_attrs or {} kws = self.default_kwargs.copy() kws.update(kwargs) - output = markdown(source, **kws) + md = Markdown(**kws) + output = md.convert(source) self.assertMultiLineEqual(output, expected) + for key, value in expected_attrs.items(): + self.assertEqual(getattr(md, key), value) def dedent(self, text): """ diff --git a/tests/test_extensions.py b/tests/test_extensions.py index 2b5f024..7a412b3 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -536,90 +536,6 @@ class TestTOC(TestCaseWithAssertStartsWith): {'level': 1, 'id': 'some-header-with-markup', 'name': 'Some Header with markup.', 'children': []}, ]) - def testAnchorLink(self): - """ Test TOC Anchorlink. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)] - ) - text = '# Header 1\n\n## Header *2*' - self.assertEqual( - md.convert(text), - '<h1 id="header-1"><a class="toclink" href="#header-1">Header 1</a></h1>\n' - '<h2 id="header-2"><a class="toclink" href="#header-2">Header <em>2</em></a></h2>' - ) - - def testAnchorLinkWithSingleInlineCode(self): - """ Test TOC Anchorlink with single inline code. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)] - ) - text = '# This is `code`.' - self.assertEqual( - md.convert(text), - '<h1 id="this-is-code">' # noqa - '<a class="toclink" href="#this-is-code">' # noqa - 'This is <code>code</code>.' # noqa - '</a>' # noqa - '</h1>' # noqa - ) - - def testAnchorLinkWithDoubleInlineCode(self): - """ Test TOC Anchorlink with double inline code. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)] - ) - text = '# This is `code` and `this` too.' - self.assertEqual( - md.convert(text), - '<h1 id="this-is-code-and-this-too">' # noqa - '<a class="toclink" href="#this-is-code-and-this-too">' # noqa - 'This is <code>code</code> and <code>this</code> too.' # noqa - '</a>' # noqa - '</h1>' # noqa - ) - - def testPermalink(self): - """ Test TOC Permalink. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(permalink=True)] - ) - text = '# Header' - self.assertEqual( - md.convert(text), - '<h1 id="header">' # noqa - 'Header' # noqa - '<a class="headerlink" href="#header" title="Permanent link">¶</a>' # noqa - '</h1>' # noqa - ) - - def testPermalinkWithSingleInlineCode(self): - """ Test TOC Permalink with single inline code. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(permalink=True)] - ) - text = '# This is `code`.' - self.assertEqual( - md.convert(text), - '<h1 id="this-is-code">' # noqa - 'This is <code>code</code>.' # noqa - '<a class="headerlink" href="#this-is-code" title="Permanent link">¶</a>' # noqa - '</h1>' # noqa - ) - - def testPermalinkWithDoubleInlineCode(self): - """ Test TOC Permalink with double inline code. """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(permalink=True)] - ) - text = '# This is `code` and `this` too.' - self.assertEqual( - md.convert(text), - '<h1 id="this-is-code-and-this-too">' # noqa - 'This is <code>code</code> and <code>this</code> too.' # noqa - '<a class="headerlink" href="#this-is-code-and-this-too" title="Permanent link">¶</a>' # noqa - '</h1>' # noqa - ) - def testTitle(self): """ Test TOC Title. """ md = markdown.Markdown( @@ -714,115 +630,6 @@ class TestTOC(TestCaseWithAssertStartsWith): '<h1 id="toc"><em>[TOC]</em></h1>' # noqa ) - def testMinMaxLevel(self): - """ Test toc_height setting """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(toc_depth='3-4')] - ) - text = '# Header 1 not in TOC\n\n## Header 2 not in TOC\n\n### Header 3\n\n####Header 4' - self.assertEqual( - md.convert(text), - '<h1>Header 1 not in TOC</h1>\n' - '<h2>Header 2 not in TOC</h2>\n' - '<h3 id="header-3">Header 3</h3>\n' - '<h4 id="header-4">Header 4</h4>' - ) - self.assertEqual( - md.toc, - '<div class="toc">\n' - '<ul>\n' # noqa - '<li><a href="#header-3">Header 3</a>' # noqa - '<ul>\n' # noqa - '<li><a href="#header-4">Header 4</a></li>\n' # noqa - '</ul>\n' # noqa - '</li>\n' # noqa - '</ul>\n' # noqa - '</div>\n' - ) - - self.assertNotIn("Header 1", md.toc) - - def testMaxLevel(self): - """ Test toc_depth setting """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(toc_depth=2)] - ) - text = '# Header 1\n\n## Header 2\n\n###Header 3 not in TOC' - self.assertEqual( - md.convert(text), - '<h1 id="header-1">Header 1</h1>\n' - '<h2 id="header-2">Header 2</h2>\n' - '<h3>Header 3 not in TOC</h3>' - ) - self.assertEqual( - md.toc, - '<div class="toc">\n' - '<ul>\n' # noqa - '<li><a href="#header-1">Header 1</a>' # noqa - '<ul>\n' # noqa - '<li><a href="#header-2">Header 2</a></li>\n' # noqa - '</ul>\n' # noqa - '</li>\n' # noqa - '</ul>\n' # noqa - '</div>\n' - ) - - self.assertNotIn("Header 3", md.toc) - - def testMinMaxLevelwithBaseLevel(self): - """ Test toc_height setting together with baselevel """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(toc_depth='4-6', - baselevel=3)] - ) - text = '# First Header\n\n## Second Level\n\n### Third Level' - self.assertEqual( - md.convert(text), - '<h3>First Header</h3>\n' - '<h4 id="second-level">Second Level</h4>\n' - '<h5 id="third-level">Third Level</h5>' - ) - self.assertEqual( - md.toc, - '<div class="toc">\n' - '<ul>\n' # noqa - '<li><a href="#second-level">Second Level</a>' # noqa - '<ul>\n' # noqa - '<li><a href="#third-level">Third Level</a></li>\n' # noqa - '</ul>\n' # noqa - '</li>\n' # noqa - '</ul>\n' # noqa - '</div>\n' - ) - self.assertNotIn("First Header", md.toc) - - def testMaxLevelwithBaseLevel(self): - """ Test toc_depth setting together with baselevel """ - md = markdown.Markdown( - extensions=[markdown.extensions.toc.TocExtension(toc_depth=3, - baselevel=2)] - ) - text = '# Some Header\n\n## Next Level\n\n### Too High' - self.assertEqual( - md.convert(text), - '<h2 id="some-header">Some Header</h2>\n' - '<h3 id="next-level">Next Level</h3>\n' - '<h4>Too High</h4>' - ) - self.assertEqual( - md.toc, - '<div class="toc">\n' - '<ul>\n' # noqa - '<li><a href="#some-header">Some Header</a>' # noqa - '<ul>\n' # noqa - '<li><a href="#next-level">Next Level</a></li>\n' # noqa - '</ul>\n' # noqa - '</li>\n' # noqa - '</ul>\n' # noqa - '</div>\n' - ) - self.assertNotIn("Too High", md.toc) - class TestSmarty(unittest.TestCase): def setUp(self): diff --git a/tests/test_syntax/extensions/test_toc.py b/tests/test_syntax/extensions/test_toc.py index a3d050c..04893e3 100644 --- a/tests/test_syntax/extensions/test_toc.py +++ b/tests/test_syntax/extensions/test_toc.py @@ -24,9 +24,397 @@ from markdown.extensions.toc import TocExtension class TestTOC(TestCase): + maxDiff = None # TODO: Move the rest of the TOC tests here. + def testAnchorLink(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Header 1 + + ## Header *2* + ''' + ), + self.dedent( + ''' + <h1 id="header-1"><a class="toclink" href="#header-1">Header 1</a></h1> + <h2 id="header-2"><a class="toclink" href="#header-2">Header <em>2</em></a></h2> + ''' + ), + extensions=[TocExtension(anchorlink=True)] + ) + + def testAnchorLinkWithSingleInlineCode(self): + self.assertMarkdownRenders( + '# This is `code`.', + '<h1 id="this-is-code">' # noqa + '<a class="toclink" href="#this-is-code">' # noqa + 'This is <code>code</code>.' # noqa + '</a>' # noqa + '</h1>', # noqa + extensions=[TocExtension(anchorlink=True)] + ) + + def testAnchorLinkWithDoubleInlineCode(self): + self.assertMarkdownRenders( + '# This is `code` and `this` too.', + '<h1 id="this-is-code-and-this-too">' # noqa + '<a class="toclink" href="#this-is-code-and-this-too">' # noqa + 'This is <code>code</code> and <code>this</code> too.' # noqa + '</a>' # noqa + '</h1>', # noqa + extensions=[TocExtension(anchorlink=True)] + ) + + def testPermalink(self): + self.assertMarkdownRenders( + '# Header', + '<h1 id="header">' # noqa + 'Header' # noqa + '<a class="headerlink" href="#header" title="Permanent link">¶</a>' # noqa + '</h1>', # noqa + extensions=[TocExtension(permalink=True)] + ) + + def testPermalinkWithSingleInlineCode(self): + self.assertMarkdownRenders( + '# This is `code`.', + '<h1 id="this-is-code">' # noqa + 'This is <code>code</code>.' # noqa + '<a class="headerlink" href="#this-is-code" title="Permanent link">¶</a>' # noqa + '</h1>', # noqa + extensions=[TocExtension(permalink=True)] + ) + + def testPermalinkWithDoubleInlineCode(self): + self.assertMarkdownRenders( + '# This is `code` and `this` too.', + '<h1 id="this-is-code-and-this-too">' # noqa + 'This is <code>code</code> and <code>this</code> too.' # noqa + '<a class="headerlink" href="#this-is-code-and-this-too" title="Permanent link">¶</a>' # noqa + '</h1>', # noqa + extensions=[TocExtension(permalink=True)] + ) + + def testMinMaxLevel(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Header 1 not in TOC + + ## Header 2 not in TOC + + ### Header 3 + + #### Header 4 + + ##### Header 5 not in TOC + ''' + ), + self.dedent( + ''' + <h1 id="header-1-not-in-toc">Header 1 not in TOC</h1> + <h2 id="header-2-not-in-toc">Header 2 not in TOC</h2> + <h3 id="header-3">Header 3</h3> + <h4 id="header-4">Header 4</h4> + <h5 id="header-5-not-in-toc">Header 5 not in TOC</h5> + ''' + ), + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#header-3">Header 3</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#header-4">Header 4</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 3, + 'id': 'header-3', + 'name': 'Header 3', + 'children': [ + { + 'level': 4, + 'id': 'header-4', + 'name': 'Header 4', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth='3-4')] + ) + + def testMaxLevel(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Header 1 + + ## Header 2 + + ### Header 3 not in TOC + ''' + ), + self.dedent( + ''' + <h1 id="header-1">Header 1</h1> + <h2 id="header-2">Header 2</h2> + <h3 id="header-3-not-in-toc">Header 3 not in TOC</h3> + ''' + ), + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#header-1">Header 1</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#header-2">Header 2</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 1, + 'id': 'header-1', + 'name': 'Header 1', + 'children': [ + { + 'level': 2, + 'id': 'header-2', + 'name': 'Header 2', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth=2)] + ) + + def testMinMaxLevelwithAnchorLink(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Header 1 not in TOC + + ## Header 2 not in TOC + + ### Header 3 + + #### Header 4 + + ##### Header 5 not in TOC + ''' + ), + '<h1 id="header-1-not-in-toc">' # noqa + '<a class="toclink" href="#header-1-not-in-toc">Header 1 not in TOC</a></h1>\n' # noqa + '<h2 id="header-2-not-in-toc">' # noqa + '<a class="toclink" href="#header-2-not-in-toc">Header 2 not in TOC</a></h2>\n' # noqa + '<h3 id="header-3">' # noqa + '<a class="toclink" href="#header-3">Header 3</a></h3>\n' # noqa + '<h4 id="header-4">' # noqa + '<a class="toclink" href="#header-4">Header 4</a></h4>\n' # noqa + '<h5 id="header-5-not-in-toc">' # noqa + '<a class="toclink" href="#header-5-not-in-toc">Header 5 not in TOC</a></h5>', # noqa + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#header-3">Header 3</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#header-4">Header 4</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 3, + 'id': 'header-3', + 'name': 'Header 3', + 'children': [ + { + 'level': 4, + 'id': 'header-4', + 'name': 'Header 4', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth='3-4', anchorlink=True)] + ) + + def testMinMaxLevelwithPermalink(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Header 1 not in TOC + + ## Header 2 not in TOC + + ### Header 3 + + #### Header 4 + + ##### Header 5 not in TOC + ''' + ), + '<h1 id="header-1-not-in-toc">Header 1 not in TOC' # noqa + '<a class="headerlink" href="#header-1-not-in-toc" title="Permanent link">¶</a></h1>\n' # noqa + '<h2 id="header-2-not-in-toc">Header 2 not in TOC' # noqa + '<a class="headerlink" href="#header-2-not-in-toc" title="Permanent link">¶</a></h2>\n' # noqa + '<h3 id="header-3">Header 3' # noqa + '<a class="headerlink" href="#header-3" title="Permanent link">¶</a></h3>\n' # noqa + '<h4 id="header-4">Header 4' # noqa + '<a class="headerlink" href="#header-4" title="Permanent link">¶</a></h4>\n' # noqa + '<h5 id="header-5-not-in-toc">Header 5 not in TOC' # noqa + '<a class="headerlink" href="#header-5-not-in-toc" title="Permanent link">¶</a></h5>', # noqa + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#header-3">Header 3</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#header-4">Header 4</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 3, + 'id': 'header-3', + 'name': 'Header 3', + 'children': [ + { + 'level': 4, + 'id': 'header-4', + 'name': 'Header 4', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth='3-4', permalink=True)] + ) + + def testMinMaxLevelwithBaseLevel(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # First Header + + ## Second Level + + ### Third Level + + #### Forth Level + ''' + ), + self.dedent( + ''' + <h3 id="first-header">First Header</h3> + <h4 id="second-level">Second Level</h4> + <h5 id="third-level">Third Level</h5> + <h6 id="forth-level">Forth Level</h6> + ''' + ), + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#second-level">Second Level</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#third-level">Third Level</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 4, + 'id': 'second-level', + 'name': 'Second Level', + 'children': [ + { + 'level': 5, + 'id': 'third-level', + 'name': 'Third Level', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth='4-5', baselevel=3)] + ) + + def testMaxLevelwithBaseLevel(self): + self.assertMarkdownRenders( + self.dedent( + ''' + # Some Header + + ## Next Level + + ### Too High + ''' + ), + self.dedent( + ''' + <h2 id="some-header">Some Header</h2> + <h3 id="next-level">Next Level</h3> + <h4 id="too-high">Too High</h4> + ''' + ), + expected_attrs={ + 'toc': ( + '<div class="toc">\n' + '<ul>\n' # noqa + '<li><a href="#some-header">Some Header</a>' # noqa + '<ul>\n' # noqa + '<li><a href="#next-level">Next Level</a></li>\n' # noqa + '</ul>\n' # noqa + '</li>\n' # noqa + '</ul>\n' # noqa + '</div>\n' # noqa + ), + 'toc_tokens': [ + { + 'level': 2, + 'id': 'some-header', + 'name': 'Some Header', + 'children': [ + { + 'level': 3, + 'id': 'next-level', + 'name': 'Next Level', + 'children': [] + } + ] + } + ] + }, + extensions=[TocExtension(toc_depth=3, baselevel=2)] + ) + def test_escaped_code(self): self.assertMarkdownRenders( self.dedent( @@ -149,7 +537,7 @@ class TestTOC(TestCase): '<h1 id="unicode-ヘッター">' # noqa 'Unicode ヘッダー' # noqa '<a class="headerlink" href="#unicode-ヘッター" title="Permanent link">¶</a>' # noqa - '</h1>', # noqa + '</h1>', # noqa extensions=[TocExtension(permalink=True, slugify=slugify_unicode)] ) @@ -157,9 +545,9 @@ class TestTOC(TestCase): from markdown.extensions.toc import slugify_unicode self.assertMarkdownRenders( '# Unicode ヘッダー', - '<h1 id="unicode-ヘッター">' # noqa - 'Unicode ヘッダー' # noqa - '<a class="headerlink" href="#unicode-ヘッター" title="パーマリンク">¶</a>' # noqa - '</h1>', # noqa + '<h1 id="unicode-ヘッター">' # noqa + 'Unicode ヘッダー' # noqa + '<a class="headerlink" href="#unicode-ヘッター" title="パーマリンク">¶</a>' # noqa + '</h1>', # noqa extensions=[TocExtension(permalink=True, permalink_title="パーマリンク", slugify=slugify_unicode)] ) |