Skip to content

Commit

Permalink
Attempt to reinvent jonschlinkert#91 for the new age
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaaaaaaaaaa committed Nov 15, 2018
1 parent 4ba79a2 commit 062b710
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Usage: markdown-toc [options] <input>
--json: Print the TOC in JSON format
--prepend <prefix>: Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")
--append: Append a string to the end of the TOC
--bullets: Bullets to use for items in the generated TOC
Expand Down Expand Up @@ -184,6 +186,10 @@ Append a string to the end of the TOC.
toc(str, {append: '\n_(TOC generated by Verb)_'});
```

### options.prepend

Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")


### options.filter

Expand Down
6 changes: 4 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var toc = require('./index.js');
var utils = require('./lib/utils');
var args = utils.minimist(process.argv.slice(2), {
boolean: ['i', 'json', 'firsth1', 'stripHeadingTags'],
string: ['append', 'bullets', 'indent'],
string: ['append', 'bullets', 'indent', 'prepend'],
default: {
firsth1: true,
stripHeadingTags: true
Expand All @@ -26,6 +26,8 @@ if (args._.length !== 1) {
'',
' --append: Append a string to the end of the TOC',
'',
' --prepend <prefix>: Prepend a string to the beginning of each link (e.g. for BitBucket "Markdown")',
'',
' --bullets: Bullets to use for items in the generated TOC',
' (Supports multiple bullets: --bullets "*" --bullets "-" --bullets "+")',
' (Default is "*".)',
Expand All @@ -37,7 +39,7 @@ if (args._.length !== 1) {
'',
' --no-stripHeadingTags: Do not strip extraneous HTML tags from heading',
' text before slugifying',
'',
'',
' --indent: Provide the indentation to use - defaults to \' \'',
' (to specify a tab, use the bash-escaped $\'\\t\')'
].join('\n'));
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ utils.slugify = function(str, options) {
if (options.num) {
str += '-' + options.num;
}
if (options.prepend) {
str = options.prepend + str;
}
return str;
};

Expand Down

0 comments on commit 062b710

Please sign in to comment.