Skip to content
Luca Davanzo edited this page Apr 3, 2015 · 11 revisions

Markdown + Summary (TOC)

This script written in Ruby simplify your live when you have to write a table of content for your markdown document.

Suppose to have written thousand of lines in your md document.. well, and now?

"Maybe I would have been build a table of contents step by step.."

Don't worry, this script will do this dirty-work for you in the blink of an eye!

For each section of your document will be generate a line in TOC.

Example:

Input

#MY DOCUMENT SECTION
##MY DOCUMENT SUBSECTION 1
##MY DOCUMENT SUBSECTION 2
###MY DOCUMENT SUBSUBSECTION 1

Output

#SUMMARY 
#MY DOCUMENT TITLE

- [MY DOCUMENT SECTION](#id-for-document-section)   
  - [MY DOCUMENT SUBSECTION 1](#id-for-document-subsection1)   
  - [MY DOCUMENT SUBSECTION 2](#id-for-document-subsection2)      
    - [MY DOCUMENT SUBSUBSECTION 1](#id-for-document-subsubsection1)      


<div id="id-for-document-section"/>
#MY DOCUMENT SECTION
<div id="id-for-document-subsection1"/>
##MY DOCUMENT SUBSECTION 1
<div id="id-for-document-subsection2"/>
##MY DOCUMENT SUBSECTION 2
<div id="id-for-document-subsubsection1"/>
###MY DOCUMENT SUBSUBSECTION 1

The will be display in this way:

#SUMMARY

#MY DOCUMENT SECTION
##MY DOCUMENT SUBSECTION 1
##MY DOCUMENT SUBSECTION 2
###MY DOCUMENT SUBSUBSECTION 1
Clone this wiki locally