Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fasermaler/markdown-linked-toc-adder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-linked-toc-adder

Add a linked Table of Contents to any GitHub flavoured Markdown file!

This script specifically adds in explicit links so you can click around the file on GitHub's web interface! (Though this should work on any web interface due to the links!)

What This Package Does

Suppose you have a Markdown file with nice headers. But they're all unlinked, and the file is thousands of words long. You don't want your readers to have to scroll through or desperately try to Ctrl-F.

So why not create a linked Table of Contents that lets you get an overview and click the links to jump to the relevant sections!

It even includes go to top functionalities!

This README was even processed with this script! WOW!

Check out this nifty dynamically generated Table of Contents Below!

Table Of Contents

  1. Check Out The Example!
    1.1 Pre-Processed
    1.2 Post-Processed
  2. Usage
    2.1 Input Markdown Files
    2.2 Running the Script

1. Check Out The Example!

1.1 Pre-Processed

go to top

File Link

1561970416824

1.2 Post-Processed

go to top

File Link

1561970478025

2. Usage

2.1 Input Markdown Files

go to top

  1. This script only processes level 2 and level 3 headers for neatness' sake

  2. Just format your Markdown Files as needed, ensuring all your headers are formatted nicely.

  3. Add a single line of "## Table Of Contents" where your want your Table of Contents to begin!

    1. The script will then process any headers that come AFTER that Table of Contents Line

      ## This header will not be processed
      .
      .
      .
      vvv Table of contents will be inserted here!
      ## Table Of Contents
      ^^^ Table of contents will be inserted here!
      
      
      ## This header will get processed
      
  4. All Level 3 headers will have a go to top link under them

2.2 Running the Script

go to top

You need Python to run the script. Run this specifically on Python 3, otherwise it doesn't behave as expected!

$ python linked_toc_adder.py <INPUT NAME> <OPTIONAL:OUTPUT NAME>

If no output file is specified, the file that is output will be prepended with toc_

You might also need to put the code where the input file is.

                            .     .
                         .  |\-^-/|  .    
                        /| } O.=.O { |\

PS: Did you know that Markdown and methylDragon have the same initials?


Yeah! Buy the DRAGON a COFFEE!

About

Script to add a TOC (with links!) to a GitHub Flavoured Markdown File!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%