Skip to content

Commit 6a1b408

Browse files
committed
Add single inline code toc tests
1 parent 56f491e commit 6a1b408

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

tests/test_extensions.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,23 @@ def testAnchorLink(self):
775775
'<h2 id="header-2"><a class="toclink" href="#header-2">Header <em>2</em></a></h2>'
776776
)
777777

778-
def testAnchorLinkWithInlineCode(self):
779-
""" Test TOC Anchorlink with inline code. """
778+
def testAnchorLinkWithSingleInlineCode(self):
779+
""" Test TOC Anchorlink with single inline code. """
780+
md = markdown.Markdown(
781+
extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)]
782+
)
783+
text = '# This is `code`.'
784+
self.assertEqual(
785+
md.convert(text),
786+
'<h1 id="this-is-code">' # noqa
787+
'<a class="toclink" href="#this-is-code">' # noqa
788+
'This is <code>code</code>.' # noqa
789+
'</a>' # noqa
790+
'</h1>' # noqa
791+
)
792+
793+
def testAnchorLinkWithDoubleInlineCode(self):
794+
""" Test TOC Anchorlink with double inline code. """
780795
md = markdown.Markdown(
781796
extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)]
782797
)
@@ -804,8 +819,22 @@ def testPermalink(self):
804819
'</h1>' # noqa
805820
)
806821

807-
def testPermalinkWithInlineCode(self):
808-
""" Test TOC Permalink with inline code. """
822+
def testPermalinkWithSingleInlineCode(self):
823+
""" Test TOC Permalink with single inline code. """
824+
md = markdown.Markdown(
825+
extensions=[markdown.extensions.toc.TocExtension(permalink=True)]
826+
)
827+
text = '# This is `code`.'
828+
self.assertEqual(
829+
md.convert(text),
830+
'<h1 id="this-is-code">' # noqa
831+
'This is <code>code</code>.' # noqa
832+
'<a class="headerlink" href="#this-is-code" title="Permanent link">&para;</a>' # noqa
833+
'</h1>' # noqa
834+
)
835+
836+
def testPermalinkWithDoubleInlineCode(self):
837+
""" Test TOC Permalink with double inline code. """
809838
md = markdown.Markdown(
810839
extensions=[markdown.extensions.toc.TocExtension(permalink=True)]
811840
)

0 commit comments

Comments
 (0)