Created
April 7, 2013 09:40
-
-
Save airekans/5329785 to your computer and use it in GitHub Desktop.
use python-markdown to generate Gitlab compatible TOC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import markdown | |
def inc_header(): data = [0] | |
def fun(x, *rest): | |
header = 'toc_%d' % data[0] | |
data[0] += 1 | |
return header | |
return fun | |
if __name__ == '__main__': | |
fd = open('test.md') | |
md_text = fd.read() | |
toc_html = markdown.markdown(md_text, extensions=['toc'], | |
extension_configs={'toc': [('slugify', inc_header())]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment