Skip to content

Commit 1f66fc2

Browse files
Attempt to reinvent jonschlinkert#91 for the new age
1 parent 4ba79a2 commit 1f66fc2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.verb.md

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Usage: markdown-toc [options] <input>
1717
1818
--json: Print the TOC in JSON format
1919
20+
--prepend: Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")
21+
2022
--append: Append a string to the end of the TOC
2123
2224
--bullets: Bullets to use for items in the generated TOC
@@ -184,6 +186,10 @@ Append a string to the end of the TOC.
184186
toc(str, {append: '\n_(TOC generated by Verb)_'});
185187
```
186188

189+
### options.prepend
190+
191+
Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")
192+
187193

188194
### options.filter
189195

cli.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var toc = require('./index.js');
55
var utils = require('./lib/utils');
66
var args = utils.minimist(process.argv.slice(2), {
77
boolean: ['i', 'json', 'firsth1', 'stripHeadingTags'],
8-
string: ['append', 'bullets', 'indent'],
8+
string: ['append', 'bullets', 'indent', 'prepend'],
99
default: {
1010
firsth1: true,
1111
stripHeadingTags: true
@@ -26,6 +26,8 @@ if (args._.length !== 1) {
2626
'',
2727
' --append: Append a string to the end of the TOC',
2828
'',
29+
' --prepend <prefix>: Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")',
30+
'',
2931
' --bullets: Bullets to use for items in the generated TOC',
3032
' (Supports multiple bullets: --bullets "*" --bullets "-" --bullets "+")',
3133
' (Default is "*".)',

lib/utils.js

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ utils.slugify = function(str, options) {
7070
if (options.num) {
7171
str += '-' + options.num;
7272
}
73+
if (options.prepend) {
74+
str = options.prepend + str;
75+
}
7376
return str;
7477
};
7578

0 commit comments

Comments
 (0)