Skip to content

Commit ce5c072

Browse files
Merge branch 'master' into stdout_edge_cases
2 parents 3b9b871 + e2f423d commit ce5c072

File tree

2 files changed

+55
-26
lines changed

2 files changed

+55
-26
lines changed

README.md

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ by github or other sites via a command line flag.
88
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
99

1010
- [Installation](#installation)
11+
- [Configuring Table of content](#configuring-table-of-content)
12+
- [TOC Title text](#toc-title-text)
13+
- [Min. heading level](#min-heading-level)
14+
- [Max. heading level](#max-heading-level)
15+
- [Include all Headings](#include-all-headings)
1116
- [Usage](#usage)
1217
- [Adding toc to all files in a directory and sub directories](#adding-toc-to-all-files-in-a-directory-and-sub-directories)
1318
- [Ignoring individual files](#ignoring-individual-files)
@@ -17,9 +22,6 @@ by github or other sites via a command line flag.
1722
- [Using doctoc to generate links compatible with other sites](#using-doctoc-to-generate-links-compatible-with-other-sites)
1823
- [Example](#example)
1924
- [Specifying location of toc](#specifying-location-of-toc)
20-
- [Specifying a custom TOC title](#specifying-a-custom-toc-title)
21-
- [Specifying a minimum heading level for TOC entries](#specifying-a-minimum-heading-level-for-toc-entries)
22-
- [Specifying a maximum heading level for TOC entries](#specifying-a-maximum-heading-level-for-toc-entries)
2325
- [Performing a dry run](#performing-a-dry-run)
2426
- [Printing to stdout](#printing-to-stdout)
2527
- [Only update existing ToC](#only-update-existing-toc)
@@ -32,6 +34,41 @@ by github or other sites via a command line flag.
3234

3335
npm install -g doctoc
3436

37+
## Configuring Table of content
38+
39+
### TOC Title text
40+
41+
Use the `--title` option to specify a (Markdown-formatted) custom TOC title; e.g., `doctoc --title '**Contents**' .` From then on, you can simply run `doctoc <file>` and doctoc will keep the title you specified.
42+
43+
Alternatively, to blank out the title, use the `--notitle` option. This will simply remove the title from the TOC.
44+
45+
### Min. heading level
46+
47+
Use the `--minlevel` option to limit TOC entries to headings only at or above the specified level; e.g., `doctoc --minlevel 2 .`
48+
49+
By default,
50+
51+
- the min level used is 1 if it is not set
52+
53+
Note: Currently supported values are only 1 and 2.
54+
55+
### Max. heading level
56+
57+
Use the `--maxlevel` option to limit TOC entries to headings only up to the specified level; e.g., `doctoc --maxlevel 3 .`
58+
59+
By default,
60+
61+
- no limit is placed on Markdown-formatted headings,
62+
- whereas headings from embedded HTML are limited to 4 levels.
63+
64+
### Include all Headings
65+
66+
Use the `--all` option to include all headings in the TOC regardless of their location
67+
68+
By default,
69+
70+
- Only headings below the TOC will be included
71+
3572
## Usage
3673

3774
In its simplest usage, you can pass one or more files or folders to the
@@ -114,32 +151,25 @@ Here we'll discuss...
114151

115152
```
116153

117-
Running doctoc will insert the toc at that location.
154+
Running doctoc will insert the toc at the specified location as illustrated below.
118155

119-
### Specifying a custom TOC title
120-
121-
Use the `--title` option to specify a (Markdown-formatted) custom TOC title; e.g., `doctoc --title '**Contents**' .` From then on, you can simply run `doctoc <file>` and doctoc will keep the title you specified.
122-
123-
Alternatively, to blank out the title, use the `--notitle` option. This will simply remove the title from the TOC.
124-
125-
### Specifying a minimum heading level for TOC entries
126-
127-
Use the `--minlevel` option to limit TOC entries to headings only at or above the specified level; e.g., `doctoc --minlevel 2 .`
128-
129-
By default,
130-
131-
- the min level used is 1 if it is not set
156+
```markdown
157+
// my_new_post.md
158+
Here we are, introducing the post. It's going to be great!
159+
But first: a TOC for easy reference.
132160

133-
Note: Currently supported values are only 1 and 2.
161+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
162+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
163+
**Contents**
134164

135-
### Specifying a maximum heading level for TOC entries
165+
- [Section One](#section-one)
136166

137-
Use the `--maxlevel` option to limit TOC entries to headings only up to the specified level; e.g., `doctoc --maxlevel 3 .`
167+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
138168

139-
By default,
169+
# Section One
140170

141-
- no limit is placed on Markdown-formatted headings,
142-
- whereas headings from embedded HTML are limited to 4 levels.
171+
Here we'll discuss...
172+
```
143173

144174
### Performing a dry run
145175

@@ -152,8 +182,6 @@ You can print to stdout by using the `-s` or `--stdout` option.
152182

153183
This option is only applicable when specifying a single filename which doctoc is to run on, if specifying a folder or multiple files the dry run option should be used.
154184

155-
[ack]: http://beyondgrep.com/
156-
157185
### Only update existing ToC
158186

159187
Use `--update-only` or `-u` to only update the existing ToC. That is, the Markdown files without ToC will be left untouched. It is good if you want to use `doctoc` with `lint-staged`.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"url": "git://github.com/thlorenz/doctoc.git"
99
},
1010
"scripts": {
11-
"test": "set -e; for t in test/*.js; do node $t; done"
11+
"test": "set -e; for t in test/*.js; do node $t; done",
12+
"doctoc": "node doctoc.js README.md --update-only"
1213
},
1314
"files": [
1415
"lib"

0 commit comments

Comments
 (0)