gen-toc

1.0.7 • Public • Published

gen-toc

CircleCI npm version code style: prettier

A Markdown "Table of Contents" generator on CLI.

Installation

$ npm install gen-toc

Usage

Prepare a markdown file named test.md like below:

$ cat test.md
# Heading1 
 
## Table of Contents 
 
## Heading2-1 
 
## Heading2-2 

You can use gen-toc to generate "Table of Contents" into test.md.

$ gen-toc ./test.md
# Heading1 
 
## Table of Contents 
 
- [Heading2-1](#Heading2-1)
- [Heading2-2](#Heading2-2)
 
## Heading2-1 
 
## Heading2-2 

If you use gen-toc with --write option, gen-toc writes to a file.

$ gen-toc --write ./test.md
test.md
Done

gen-toc format a markdown with Prettier on default. If you don't want gen-toc to format, you can add --noformat option.

If you don't want to use a heading of ## Table of Contents, you can use a comment of <-- Table of Contents --> instead of a heading.

$ cat test.md
# Heading1 
 
<!-- Table of Contents -->
 
## Heading2-1 
 
## Heading2-2 
 
$ gen-toc test.md
# Heading1 
 
<!-- Table of Contents -->
 
- [Heading2-1](#Heading2-1)
- [Heading2-2](#Heading2-2)
 
## Heading2-1 
 
## Heading2-2 

LICENSE

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.7
    0
    • latest

Version History

Package Sidebar

Install

npm i gen-toc

Weekly Downloads

4

Version

1.0.7

License

MIT

Unpacked Size

22.4 kB

Total Files

14

Last publish

Collaborators

  • sosukesuzuki