Total Pageviews

Tuesday, 4 March 2014

用Python-Markdown给md文件添加“内容表”(即table of contents)

So you finished writing a long article with Markdown and want a table of contents? Use Python-Markdown!
Just install it by:
pip install markdown 
And add [TOC] to your markdown file, like this:
# I like Python-Markdown
[TOC]
## What is Python-Markdown?
## Why do I like it?
### I just like it.
### Try it and you'll like it too.
Now run the following command:
python -m markdown -x toc input.md > output.html    
You can see for yourself the result in output.html