MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / TestTOC

Class TestTOC

tests/test_syntax/extensions/test_toc.py:28–1410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28class TestTOC(TestCase):
29 maxDiff = None
30 default_kwargs = {
31 'extensions': [TocExtension()]
32 }
33
34 def testTOCMarker(self):
35 self.assertMarkdownRenders(
36 self.dedent(
37 '''
38 [TOC]
39
40 # Header 1
41
42 ## Header 2
43 '''
44 ),
45 '<div class="toc">\n'
46 '<ul>\n' # noqa
47 '<li><a href="#header-1">Header 1</a>' # noqa
48 '<ul>\n' # noqa
49 '<li><a href="#header-2">Header 2</a></li>\n' # noqa
50 '</ul>\n' # noqa
51 '</li>\n' # noqa
52 '</ul>\n' # noqa
53 '</div>\n'
54 '<h1 id="header-1">Header 1</h1>\n'
55 '<h2 id="header-2">Header 2</h2>'
56 )
57
58 def testNoTOCMarker(self):
59 self.assertMarkdownRenders(
60 self.dedent(
61 ''&#x27;
62 # Header 1
63
64 ## Header 2
65 ''&#x27;
66 ),
67 self.dedent(
68 ''&#x27;
69 <h1 id="header-1">Header 1</h1>
70 <h2 id="header-2">Header 2</h2>
71 ''&#x27;
72 ),
73 expected_attrs={
74 'toc': (
75 '<div class="toc">\n'
76 '<ul>\n' # noqa
77 '<li><a href="#header-1">Header 1</a>' # noqa
78 '<ul>\n' # noqa
79 '<li><a href="#header-2">Header 2</a></li>\n' # noqa
80 '</ul>\n' # noqa
81 '</li>\n' # noqa
82 '</ul>\n' # noqa
83 '</div>\n'
84 )
85 }

Callers

nothing calls this directly

Calls 1

TocExtensionClass · 0.90

Tested by

no test coverage detected