From 6cd4b7df93aebdfdd24a63908ba9358f46ddb89c Mon Sep 17 00:00:00 2001 From: Evgeniy Gavryushin Date: Fri, 19 Dec 2014 14:26:45 +0300 Subject: [PATCH] Fix EOL for different OS --- lib/toc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/toc.js b/lib/toc.js index 1c882a6..2129ff9 100644 --- a/lib/toc.js +++ b/lib/toc.js @@ -1,5 +1,6 @@ var marked = require('marked'), - utils = require('./utils'); + utils = require('./utils'), + EOL = require('os').EOL; /** * Generates a TOC object @@ -20,7 +21,7 @@ module.exports = function (source, options) { if (tocIndex === -1) return toc; toc.index = tocIndex + ''.length; - toc.data = '\n'; + toc.data = EOL; var tocSource = source.substring(toc.index), usedHeaders = [], @@ -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({ @@ -53,7 +54,7 @@ module.exports = function (source, options) { toc.data += indent + tocElem; } - toc.data += '\n' + ''; + toc.data += EOL + ''; return toc; };