You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,6 +34,41 @@ by github or other sites via a command line flag.
32
34
33
35
npm install -g doctoc
34
36
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
+
35
72
## Usage
36
73
37
74
In its simplest usage, you can pass one or more files or folders to the
@@ -114,32 +151,25 @@ Here we'll discuss...
114
151
115
152
```
116
153
117
-
Running doctoc will insert the toc at that location.
154
+
Running doctoc will insert the toc at the specified location as illustrated below.
118
155
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.
132
160
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**
134
164
135
-
### Specifying a maximum heading level for TOC entries
165
+
- [Section One](#section-one)
136
166
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 -->
138
168
139
-
By default,
169
+
# Section One
140
170
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
+
```
143
173
144
174
### Performing a dry run
145
175
@@ -152,8 +182,6 @@ You can print to stdout by using the `-s` or `--stdout` option.
152
182
153
183
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.
154
184
155
-
[ack]: http://beyondgrep.com/
156
-
157
185
### Only update existing ToC
158
186
159
187
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`.
0 commit comments