diff options
author | Waylan Limberg <waylan@gmail.com> | 2013-02-19 11:00:38 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2013-02-19 11:00:38 -0500 |
commit | e5e07c3746358fc70afc2e5b0344a5e7573b444a (patch) | |
tree | 5124591a538876a7a1f9eea31a3eb39b5cde5ad8 /tests | |
parent | 53a7fc80f12cc1da699c2a7f56da13da32e6de8f (diff) | |
download | markdown-e5e07c3746358fc70afc2e5b0344a5e7573b444a.tar.gz markdown-e5e07c3746358fc70afc2e5b0344a5e7573b444a.tar.bz2 markdown-e5e07c3746358fc70afc2e5b0344a5e7573b444a.zip |
Ensure toc attribute is available on Markdown class.
This appears to have recently been broken with the fixes in #191.
This time I've added tests to prevent future breakage and added
documentation to explain the behavior.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_extensions.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py index bee270a..fa9a801 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -371,3 +371,42 @@ class TestAdmonition(unittest.TestCase): ] for test, expected in tests: self.assertEqual(RE.match(test).groups(), expected) + +class TestTOC(unittest.TestCase): + """ Test TOC Extension. """ + + def setUp(self): + self.md = markdown.Markdown(extensions=['toc']) + + def testMarker(self): + """ Test TOC with a Marker. """ + text = '[TOC]\n\n# Header 1\n\n## Header 2' + self.assertEqual(self.md.convert(text), + '<div class="toc">\n' + '<ul>\n' + '<li><a href="#header-1">Header 1</a>' + '<ul>\n' + '<li><a href="#header-2">Header 2</a></li>\n' + '</ul>\n' + '</li>\n' + '</ul>\n' + '</div>\n' + '<h1 id="header-1">Header 1</h1>\n' + '<h2 id="header-2">Header 2</h2>') + + def testNoMarker(self): + """ Test TOC without a Marker. """ + text = '# Header 1\n\n## Header 2' + self.assertEqual(self.md.convert(text), + '<h1 id="header-1">Header 1</h1>\n' + '<h2 id="header-2">Header 2</h2>') + self.assertEqual(self.md.toc, + '<div class="toc">\n' + '<ul>\n' + '<li><a href="#header-1">Header 1</a>' + '<ul>\n' + '<li><a href="#header-2">Header 2</a></li>\n' + '</ul>\n' + '</li>\n' + '</ul>\n' + '</div>\n')
\ No newline at end of file |