From fb82bf02abd9580cb46a69b4b3520b96e8ac96c1 Mon Sep 17 00:00:00 2001 From: macca16 Date: Fri, 28 Oct 2016 15:42:03 +0100 Subject: [PATCH] Fix issues with nested ordered/unordered lists --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 418cbd4..35ddd10 100644 --- a/index.js +++ b/index.js @@ -61,7 +61,12 @@ _.extend(Renderer.prototype, rawRenderer.prototype, { return line }) var type = ordered ? '#' : '*' - return _.map(arr, function(line) { + // prefix with a \n to prevent the first child list item being concatenated onto the parent + return '\n' + _.map(arr, function(line) { + // only insert a space if we have terminated any ordered/unordered list demarkation + if (line.match(/^[*#]+\s.*/)) { + return type + line + } return type + ' ' + line }).join('\n') + '\n\n'