toc

toc TOC, table of content generator for Markdown files

toc gif


Usage

Usage: toc [options]
Options:
	-p, --path         Path for the markdown file.                               [REQUIRED]
	-a, --append       Append toc after , or write to stdout.          [Default: true]
	-b, --bulleted     Write as bulleted, or write as numbered list.             [Default: true] 
	-s, --skip          Skip the first given number of headers.                   [Default: 0]
	-d, --depth         Set the number of maximum heading level to be included.   [Default: 6]
	-h, --help               Show this message and exit.

Add to your markdown to the place where you want to add Table of Contents. That’s it.

Give the markdown file as an input with -p, --path flags.

$ toc -p path/to/markdown.md

Create numbered list instead of bulleted list.

$ toc --bulleted=false

Write result to standard output instead of appending.

$ toc --append=false

Skip the first n number of headers via -s, --skip flags.

$ toc --skip 2

Set the number of maximum heading level to be included with -d, --depth flags.

Set maximum heading level to 3 (h3)

$ toc --depth 3

Installation

Packages

Arch Linux

  • For Arch Linux, install the package.

Homebrew

  • For Homebrew on macOS, install the formula.

Docker

It is available via two tags.

You can either use latest or $VERSION.

docker run --rm -it yagizcan/toc:latest toc

Downloads

Binary downloads of example are available from the releases section on GitHub for 64-bit Windows, macOS, and Linux targets. They contain the compiled executable.

platform
macOS 64 Bit
Linux 32-Bit
Linux ARM 64 Bit
Linux 64 Bit
Windows 64 Bit
Windows 32 Bit

Installation from source

  1. Verify that you have Go 1.13+ installed

    $ go version
    

    If go is not installed, follow instructions on the Go website.

  2. Clone this repository

    $ git clone https://github.com/ycd/toc 
    $ cd ycd
    
  3. Build and install

    Unix/Linux

    # May require you to use sudo
    $ go build .
    $ cp toc /usr/local/toc
    
  4. Verify installation

    $ toc -h 
    
    Usage: toc [options]
    Options:
       -p, --path         Path for the markdown file.                               [REQUIRED]
       -a, --append       Append toc after , or write to stdout.          [Default: true]
       -b, --bulleted     Write as bulleted, or write as numbered list.             [Default: true] 
       -s, --skip          Skip the first given number of headers.                   [Default: 0]
       -d, --depth         Set the number of maximum heading level to be included.   [Default: 6]
       -h, --help               Show this message and exit.
    

Contributing

All kinds of Pull Requests and Feature Requests are welcomed!

Licence

toc’s source code is licenced under the Apache 2.0 License.

GitHub

https://github.com/ycd/toc