예제 #1
0
    def test_input_string_get_html_toc(self):
        md = Markdown('# header-1\n## header-2\n### header-3')
        html = md.get_html_toc()

        self.assertEqual(
            html, (
                '\n '
                '<ul>\n <li><a href="#header-1">header-1</a>\n  '
                '<ul>\n  <li><a href="#header-2">header-2</a>\n   '
                '<ul>\n   <li><a href="#header-3">header-3</a>   </li>\n   '
                '</ul>\n  </li>\n  </ul>\n </li>\n </ul>\n'
            )
        )
예제 #2
0
    def test_input_file_get_html_toc(self):
        i = tempfile.TemporaryFile('r+w')
        i.write('# header-1\n## header-2\n### header-3')
        i.seek(0)
        md = Markdown(i)
        html = md.get_html_toc()
        i.close()

        self.assertEqual(
            html, (
                '\n '
                '<ul>\n <li><a href="#header-1">header-1</a>\n  '
                '<ul>\n  <li><a href="#header-2">header-2</a>\n   '
                '<ul>\n   <li><a href="#header-3">header-3</a>   </li>\n   '
                '</ul>\n  </li>\n  </ul>\n </li>\n </ul>\n'
            )
        )