Skip to content

Commit

Permalink
Add toc permalink tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minddust committed Mar 17, 2016
1 parent 935d55b commit 56f491e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,34 @@ def testAnchorLinkWithInlineCode(self):
'</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">&para;</a>' # noqa
'</h1>' # noqa
)

def testPermalinkWithInlineCode(self):
""" Test TOC Permalink with 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">&para;</a>' # noqa
'</h1>' # noqa
)

def testTitle(self):
""" Test TOC Title. """
md = markdown.Markdown(
Expand Down

0 comments on commit 56f491e

Please sign in to comment.