diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-04 22:08:32 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-04 22:08:32 +0000 |
| commit | a2ca75c71bbbc645d51a41abcf430d3c3a922c82 (patch) | |
| tree | 6805dd2f32b01c01f557f55c9a1faea7dbc8cc22 | |
| parent | f470e042dd30004c7c2921bb01236ef4bd65ef57 (diff) | |
Handle list items outside of lists in Markdown writer
| -rw-r--r-- | lib/writers/markdown-writer.js | 1 | ||||
| -rw-r--r-- | tests/writers/markdown-writer.tests.js | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js index 82f19dc..d6adb56 100644 --- a/lib/writers/markdown-writer.js +++ b/lib/writers/markdown-writer.js @@ -42,6 +42,7 @@ function markdownList(options) { } function markdownListItem(attributes, list) { + list = list || {indent: 0, isOrdered: false, count: 0}; list.count++; var start = repeatString("\t", list.indent) + (list.isOrdered ? list.count + "." : "-") + " "; diff --git a/tests/writers/markdown-writer.tests.js b/tests/writers/markdown-writer.tests.js index 250bb0c..6b595f2 100644 --- a/tests/writers/markdown-writer.tests.js +++ b/tests/writers/markdown-writer.tests.js @@ -123,6 +123,14 @@ describe('markdown-writer', function() { return assert.equal(writer.asString(), ""); }); + test('list item outside of list is treated as unordered list', function() { + var writer = mdWriter.writer(); + writer.open("li"); + writer.text("Hello"); + writer.close("li"); + return assert.equal(writer.asString(), "- Hello\n"); + }); + test('can generate an ordered list', function() { var writer = mdWriter.writer(); writer.open("ol"); |
