aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_extensions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_extensions.py')
-rw-r--r--tests/test_extensions.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 532ed6f..5489887 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -852,24 +852,40 @@ class TestTOC(TestCaseWithAssertStartsWith):
def testWithAttrList(self):
""" Test TOC with attr_list Extension. """
md = markdown.Markdown(extensions=['toc', 'attr_list'])
- text = '# Header 1\n\n## Header 2 { #foo }'
+ text = '# Header 1\n\n## Header 2 { #foo }\n\n## Header 3 { data-toc-label="Foo Bar"}'
self.assertEqual(
md.convert(text),
'<h1 id="header-1">Header 1</h1>\n'
- '<h2 id="foo">Header 2</h2>'
+ '<h2 id="foo">Header 2</h2>\n'
+ '<h2 id="header-3">Header 3</h2>'
)
self.assertEqual(
md.toc,
'<div class="toc">\n'
- '<ul>\n' # noqa
- '<li><a href="#header-1">Header 1</a>' # noqa
- '<ul>\n' # noqa
- '<li><a href="#foo">Header 2</a></li>\n' # noqa
- '</ul>\n' # noqa
- '</li>\n' # noqa
- '</ul>\n' # noqa
+ '<ul>\n' # noqa
+ '<li><a href="#header-1">Header 1</a>' # noqa
+ '<ul>\n' # noqa
+ '<li><a href="#foo">Header 2</a></li>\n' # noqa
+ '<li><a href="#header-3">Foo Bar</a></li>\n' # noqa
+ '</ul>\n' # noqa
+ '</li>\n' # noqa
+ '</ul>\n' # noqa
'</div>\n'
)
+ self.assertEqual(
+ md.toc_tokens,
+ [
+ {
+ 'level': 1,
+ 'id': 'header-1',
+ 'name': 'Header 1',
+ 'children': [
+ {'level': 2, 'id': 'foo', 'name': 'Header 2', 'children': []},
+ {'level': 2, 'id': 'header-3', 'name': 'Foo Bar', 'children': []}
+ ]
+ }
+ ]
+ )
def testUniqueFunc(self):
""" Test 'unique' function. """