Markdown Table of Contents generator


Some ruby and shell code to generate Table of Contents for your Markdown document. The original version of the ruby code is available here generate_toc.rb

(Author albertodebortoli)

How it works

  • Script search *md file
    • For each md file found, the script check if a TOC is already generated
    • Generate TOC using generate_toc_rb script
    • Check if TOC can be generated for this md file
      • Copy TOC in the md file
  • Finaly you have to add/commit/push your nice MD file to your repo 😉

you can use this script for lazy poeple gacp script


Download Repo

git clone

Copy scripts to /usr/bin

cd md_TOC_generator
sudo cp generate_toc* /usr/bin/


generate_toc /home/shitana
  Generate TOC in progress for /home/shitana/github/md_TOC_generator/
  TOC already exists for /home/shitana/github/git_tools/