Skip to content

A table of contents generator for markdown, written in python.

License

Notifications You must be signed in to change notification settings

Chris3606/TOC-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TOC-Generator

A table of contents generator for markdown, written in python. Inspired by many of the table-of-contents generators that already exist, particularly markdown-toc.

Premise

I maintain a github project that has a wiki, and needed a lightweight method to automatically generate tables of contents for select pages. I wanted to automatically insert and update those tables of contents with minimal effort. Thus, I created a python script to accomplish this.

Installation/Prerequisites

The system consists of a single python script, requiring >= Python v3.5 to run.

Usage

  1. In all markdown files in your project that you want to generate tables of contents for, insert the following tags into the file, where you want the table of contents to be placed:
<!--ts-->
<!--te-->

When the script is run, all text in between those two tags will be replaced with the table of contents. Furthermore, the tags themselves will (obviously) not appear in the markdown view on GitHub, as they are html comments.

  1. Run the included python script, passing as a command-line argument the directory of your project. The script will automatically locate any markdown files (with .md extensions) within that folder and all subfolders. It will scan them for the above tags. If found, it will generate the table of contents for them, and replace any text inside the tags with the new table of contents. Any file in which the tags can't be located will not be modified.

Examples

For examples of TOC's generated with this utility, see any number of pages in the GoRogue wiki.

About

A table of contents generator for markdown, written in python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages