aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2016-03-17 13:36:27 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2016-03-17 13:36:27 -0400
commit8eed88621d0bae57f8e72a795c70367e88161f89 (patch)
tree7ebeec737ba40971295aa31b49ca97cb5aef65c9 /tests
parent08d81b0e1e38b7662d4a8837c1b6a229b7082482 (diff)
parent803ab63609d6a148b01d6afc12f841501a5fd84c (diff)
downloadmarkdown-8eed88621d0bae57f8e72a795c70367e88161f89.tar.gz
markdown-8eed88621d0bae57f8e72a795c70367e88161f89.tar.bz2
markdown-8eed88621d0bae57f8e72a795c70367e88161f89.zip
Merge pull request #462 from waylan/toc_bug
Toc bug
Diffstat (limited to 'tests')
-rw-r--r--tests/test_extensions.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 6d47e0e..19a1389 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -775,6 +775,78 @@ class TestTOC(TestCaseWithAssertStartsWith):
'<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">&para;</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">&para;</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">&para;</a>' # noqa
+ '</h1>' # noqa
+ )
+
def testTitle(self):
""" Test TOC Title. """
md = markdown.Markdown(