diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-04 21:57:13 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-04 21:57:13 +0000 |
| commit | 77f14a8c805516788f6ee75c53e6cde4f12fea83 (patch) | |
| tree | 0faad9f0d8e499b49d93922ef3ef0ed072f2343d | |
| parent | ee35844a13ee4835bde8ba1969f0fd2ec042f23c (diff) | |
Initialise list state to null
| -rw-r--r-- | lib/writers/markdown-writer.js | 14 |
1 files changed, 5 insertions, 9 deletions
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 || {}; |
