From e5e07c3746358fc70afc2e5b0344a5e7573b444a Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 19 Feb 2013 11:00:38 -0500 Subject: 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. --- tests/test_extensions.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') 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), + '
\n' + '\n' + '
\n' + '

Header 1

\n' + '

Header 2

') + + def testNoMarker(self): + """ Test TOC without a Marker. """ + text = '# Header 1\n\n## Header 2' + self.assertEqual(self.md.convert(text), + '

Header 1

\n' + '

Header 2

') + self.assertEqual(self.md.toc, + '
\n' + '\n' + '
\n') \ No newline at end of file -- cgit v1.2.3