Waitfish
8/25/2019 - 9:18 AM

[markdown_to_toc]make_markdown_to_html#toc #python_markdown

[markdown_to_toc]make_markdown_to_html#toc #python_markdown

import markdown
from markdown.extensions.toc import TocExtension
s="""
[TOC]
# test1
## test2
### test2.2
## test3
"""
html = markdown.markdown(s, extensions=[TocExtension(baselevel=3,anchorlink=True)])


'<div class="toc">\n<ul>\n<li><a href="#test1">test1</a><ul>\n<li><a href="#test2">test2</a><ul>\n<li><a href="#test22">test2.2</a></li>\n</ul>\n</li>\n<li><a href="#test3">test3</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<h3 id="test1"><a class="toclink" href="#test1">test1</a><a class="headerlink" href="#test1" title="Permanent link">&para;</a></h3>\n<h4 id="test2"><a class="toclink" href="#test2">test2</a><a class="headerlink" href="#test2" title="Permanent link">&para;</a></h4>\n<h5 id="test22"><a class="toclink" href="#test22">test2.2</a><a class="headerlink" href="#test22" title="Permanent link">&para;</a></h5>\n<h4 id="test3"><a class="toclink" href="#test3">test3</a><a class="headerlink" href="#test3" title="Permanent link">&para;</a></h4>'