From 062b7108c515faaa0a8010876fcc69e053540b05 Mon Sep 17 00:00:00 2001 From: "Svyatoslav I. Maslennikov" Date: Thu, 15 Nov 2018 11:29:40 -0800 Subject: [PATCH] Attempt to reinvent #91 for the new age --- .verb.md | 6 ++++++ cli.js | 6 ++++-- lib/utils.js | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.verb.md b/.verb.md index bdd7611..89f48c3 100644 --- a/.verb.md +++ b/.verb.md @@ -17,6 +17,8 @@ Usage: markdown-toc [options] --json: Print the TOC in JSON format + --prepend : 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 @@ -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 diff --git a/cli.js b/cli.js index 87dd4c0..f2dc3b0 100755 --- a/cli.js +++ b/cli.js @@ -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 @@ -26,6 +26,8 @@ if (args._.length !== 1) { '', ' --append: Append a string to the end of the TOC', '', + ' --prepend : 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 "*".)', @@ -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')); diff --git a/lib/utils.js b/lib/utils.js index 16125e2..86b0db0 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -70,6 +70,9 @@ utils.slugify = function(str, options) { if (options.num) { str += '-' + options.num; } + if (options.prepend) { + str = options.prepend + str; + } return str; };