Skip to content

maksyche/github-md-toc-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Markdown Table of Contents Generator

This is a convenient (at least for me) markdown ToC generator.

Installation and Usage

  • Download the script:
wget https://raw.githubusercontent.com/maksyche/github-md-toc-generator/master/toc_generator.py
  • Run it:
python3 toc_generator.py
python3 toc_generator.py -d # Run with DEBUG log level

Results

  • IMPORTANT: The script adds ToC to the files right below the lvl1 heading. Everything between the lvl1 and the first lvl2 headings is replaced with the ToC.
  • Check this example:
# Lvl1
* [Lvl2 with . a dot](#lvl2-with--a-dot)
    * [Lvl3 with an _underscore](#lvl3-with-an-_underscore)
    * [Lvl3 with _underscores_](#lvl3-with-underscores)
* [Lvl2 with a *star](#lvl2-with-a-star)
* [Lvl2 with *stars*](#lvl2-with-stars)
* [Lvl2 with `./inline-code`](#lvl2-with-inline-code)
    * [Lvl3 `_with _underscores_` inside and outside_ of code](#lvl3-_with-_underscores_-inside-and-outside_-of-code)
        * [Lvl4](#lvl4)
            * [Lvl5](#lvl5)
                * [Lvl6](#lvl6)
* [Lvl2 with a ~tilda](#lvl2-with-a-tilda)
* [Lvl2 with a +plus](#lvl2-with-a-plus)
* [Lvl2 with an 'apostrophe](#lvl2-with-an-apostrophe)

## Lvl2 with . a dot
### Lvl3 with an _underscore
### Lvl3 with _underscores_
## Lvl2 with a *star
## Lvl2 with *stars*
## Lvl2 with `./inline-code`
### Lvl3 `_with _underscores_` inside and outside_ of code
#### Lvl4
##### Lvl5
###### Lvl6
####### There's no lvl7
## Lvl2 with a ~tilda
## Lvl2 with a +plus
## Lvl2 with an 'apostrophe

Ignore Files

  • Create the .tocignore file in the current folder.
  • Put some regex patterns for files and folders that should be ignored. Currently, only regex patterns are supported (no ignorelang for now). Example:
README.md
somefile.md
somefolder/+.*
someotherfolder/someotherfile.md