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
add cli flag to prevent doctoc from adding toc to a file without toc.
this is good for CI or the combination with [`lint-staged`](https://github.com/okonet/lint-staged).
with -p, doctoc will update toc if md has toc sectioon, otherwise doctoc keep it unmodified.
I'm not sure `preserve` is the right name for it. so please change it if you have a better one.
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,10 @@ You can print to stdout by using the `-s` or `--stdout` option.
140
140
141
141
[ack]: http://beyondgrep.com/
142
142
143
+
### Only update existing ToC
144
+
145
+
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`.
146
+
143
147
### Usage as a `git` hook
144
148
145
149
doctoc can be used as a [pre-commit](http://pre-commit.com) hook by using the
outputFunc('Usage: doctoc [mode] [--entryprefix prefix] [--notitle | --title title] [--maxlevel level] [--all] <path> (where path is some path to a directory (e.g., .) or a file (e.g., README.md))');
65
+
outputFunc('Usage: doctoc [mode] [--entryprefix prefix] [--notitle | --title title] [--maxlevel level] [--all] [--update-only] <path> (where path is some path to a directory (e.g., .) or a file (e.g., README.md))');
@@ -99,6 +103,7 @@ var notitle = argv.T || argv.notitle;
99
103
varentryPrefix=argv.entryprefix||'-';
100
104
varprocessAll=argv.all;
101
105
varstdOut=argv.s||argv.stdout
106
+
varupdateOnly=argv.u||argv['update-only']
102
107
103
108
varmaxHeaderLevel=argv.m||argv.maxlevel;
104
109
if(maxHeaderLevel&&isNaN(maxHeaderLevel)||maxHeaderLevel<0){console.error('Max. heading level specified is not a positive number: '+maxHeaderLevel),printUsageAndExit(true);}
@@ -115,7 +120,7 @@ for (var i = 0; i < argv._.length; i++) {
0 commit comments