From 77f14a8c805516788f6ee75c53e6cde4f12fea83 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 4 Feb 2015 21:57:13 +0000 Subject: Initialise list state to null --- lib/writers/markdown-writer.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js index 6fed677..5db7cab 100644 --- a/lib/writers/markdown-writer.js +++ b/lib/writers/markdown-writer.js @@ -30,11 +30,11 @@ function markdownImage(attributes) { function markdownList(options) { return function(attributes, list) { return { - start: list.indent > -1 ? "\n" : "", - end: list.indent > -1 ? "" : "\n", + start: list ? "\n" : "", + end: list ? "" : "\n", list: { isOrdered: options.isOrdered, - indent: list.indent + 1, + indent: list ? list.indent + 1 : 0, count: 0 } }; @@ -43,7 +43,7 @@ function markdownList(options) { function markdownListItem(attributes, list) { list.count++; - var start = repeatString("\t", Math.max(list.indent, 0)) + + var start = repeatString("\t", list.indent) + (list.isOrdered ? list.count + "." : "-") + " "; return {start: start, end: "\n"}; @@ -78,11 +78,7 @@ function repeatString(value, count) { function markdownWriter() { var fragments = []; var elementStack = []; - var list = { - indent: -1, - isOrdered: false, - count: 0 - }; + var list = null; function open(tagName, attributes) { attributes = attributes || {}; -- cgit v1.2.3