Skip to content

Commit

Permalink
Bitbucket mode uses 4 spaces for nested lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
plumlee committed Jan 19, 2015
1 parent 573eb0e commit 83e9869
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/transform.js
Original file line number Diff line number Diff line change
@@ -136,13 +136,16 @@ exports = module.exports = function transform(content, mode, maxHeaderNo) {

if (linkedHeaders.length === 0) return { transformed: false };

// 4 spaces required for proper indention on Bitbucket
var indentionAmount = (mode === 'bitbucket.org' ? ' ' : ' ');

var toc =
'**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*'
+ '\n\n'
+ linkedHeaders
.map(function (x) {
var indent = _(_.range(x.rank - lowestRank))
.reduce(function (acc, x) { return acc + ' '; }, '');
.reduce(function (acc, x) { return acc + indentionAmount; }, '');

return indent + '- ' + x.anchor;
})
8 changes: 4 additions & 4 deletions test/transform.js
Original file line number Diff line number Diff line change
@@ -237,10 +237,10 @@ check(
].join('\n')
, [ '**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n'
, '- [My Module](#markdown-header-my-module)\n'
, ' - [API](#markdown-header-api)\n'
, ' - [Method One](#markdown-header-method-one)\n'
, ' - [Method Two](#markdown-header-method-two)\n'
, ' - [Main Usage](#markdown-header-main-usage)\n\n\n'
, ' - [API](#markdown-header-api)\n'
, ' - [Method One](#markdown-header-method-one)\n'
, ' - [Method Two](#markdown-header-method-two)\n'
, ' - [Main Usage](#markdown-header-main-usage)\n\n\n'
].join('')
, 'bitbucket.org'
)

0 comments on commit 83e9869

Please sign in to comment.