samoht / toc

Automatically generate table of contents for Markdown files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TOC - Manage Tables of Contents in Markdown Files

This repository contains a simple utility to manage tables of contents for Github Markdown files.

Usage

First Use

Run:

$ toc README.md
README.md has been updated.

This will replace any [toc] tokens by the file's table of contents instead.

-[toc]
+<div class="toc">
+
+* [Usage](#Usage)
+  * [First Use](#First-Use)
+  * [Regenerate TOC](#Regenerate-TOC)
+  * [Multiple TOC](#Multiple-TOC)
+  * [Options](#Options)
+    * [Print](#Print)
+    * [Depth](#Depth)
+* [License](#License)
+
+</div>

Regenerate TOC

toc adds transparent <div> markers around the generated table of contents. Hence, the next call to toc will update the table correctly.

To regenerate the TOC, run:

$ toc README.md
README.md has been updated.

Multiple TOC

Use as many [toc] as you like to define multiple table of contents the same file.

Options

Use toc --help to see all the options.

Print

$ toc README.md -p
* Usage
  * First Use
  * Regenerate TOC
  * Multiple TOC
  * Options
    * Print
    * Depth
* License

Depth

Use --depth to control the depth of the table of contents.

$ toc README.md -p -d 1
* Usage
* License

License

ISC. See the LICENSE file.

About

Automatically generate table of contents for Markdown files

License:ISC License


Languages

Language:OCaml 100.0%