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