1 | # DocToc [![build status](https://secure.travis-ci.org/thlorenz/doctoc.png)](http://travis-ci.org/thlorenz/doctoc)
|
2 |
|
3 | [![NPM](https://nodei.co/npm/doctoc.png?downloads=true&stars=true)](https://nodei.co/npm/doctoc/)
|
4 |
|
5 | Generates table of contents for markdown files inside local git repository. Links are compatible with anchors generated
|
6 | by github or bitbucket via a command line flag.
|
7 |
|
8 | **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
|
9 |
|
10 | - [Installation](#installation)
|
11 | - [Usage](#usage)
|
12 | - [Adding toc to all files in a directory and sub directories](#adding-toc-to-all-files-in-a-directory-and-sub-directories)
|
13 | - [Adding toc to a single file](#adding-toc-to-a-single-file)
|
14 | - [Example](#example)
|
15 | - [Using doctoc to generate bitbucket compatible links](#using-doctoc-to-generate-bitbucket-compatible-links)
|
16 |
|
17 | ## Installation
|
18 |
|
19 | npm install -g doctoc
|
20 |
|
21 | ## Usage
|
22 |
|
23 | ### Adding toc to all files in a directory and sub directories
|
24 |
|
25 | Go into the directory that contains you local git project and type:
|
26 |
|
27 | doctoc .
|
28 |
|
29 | This will update all markdown files in the current directory and all its
|
30 | subdirectories with a table of content that will point at the anchors generated
|
31 | by the github markdown parser.
|
32 |
|
33 | ### Adding toc to a single file
|
34 |
|
35 | If you want to convert only a specific file, do:
|
36 |
|
37 | doctoc /path/to/file
|
38 |
|
39 | #### Example
|
40 |
|
41 | doctoc README.md
|
42 |
|
43 | ### Using doctoc to generate bitbucket compatible links
|
44 |
|
45 | In order to add a table of contents whose links are compatible with anchors generated by
|
46 | [bitbucket](https://bitbucket.org/), supply a `--bitbucket` flag to doctoc.
|
47 |
|
48 | doctoc README.md --bitbucket
|
49 |
|
50 |
|
51 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thlorenz/doctoc/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
52 |
|