Skip to content

Commit

Permalink
Fix EOL for different OS
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Dec 19, 2014
1 parent 932987f commit 6cd4b7d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/toc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var marked = require('marked'),
utils = require('./utils');
utils = require('./utils'),
EOL = require('os').EOL;

/**
* Generates a TOC object
Expand All @@ -20,7 +21,7 @@ module.exports = function (source, options) {
if (tocIndex === -1) return toc;

toc.index = tocIndex + '<!-- TOC -->'.length;
toc.data = '\n';
toc.data = EOL;

var tocSource = source.substring(toc.index),
usedHeaders = [],
Expand All @@ -42,7 +43,7 @@ module.exports = function (source, options) {
cache[href] = 1;
}

var tocElem = '* [' + header.text.replace(/\\/g, '\\\\') + '](#' + href + ')' + '\n',
var tocElem = '* [' + header.text.replace(/\\/g, '\\\\') + '](#' + href + ')' + EOL,
indent = utils.getIndent(usedHeaders, header.depth);

usedHeaders.unshift({
Expand All @@ -53,7 +54,7 @@ module.exports = function (source, options) {
toc.data += indent + tocElem;
}

toc.data += '\n' + '<!-- TOC END -->';
toc.data += EOL + '<!-- TOC END -->';

return toc;
};

0 comments on commit 6cd4b7d

Please sign in to comment.