aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/writers/markdown-writer.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js
index 9f09e34..5a6f5e0 100644
--- a/lib/writers/markdown-writer.js
+++ b/lib/writers/markdown-writer.js
@@ -29,8 +29,8 @@ function markdownImage(attributes) {
function markdownList(attributes, list) {
return {
- start: list.indent > -1 ? "\n" : "",
- end: list.indent > -1 ? "" : "\n"
+ start: list.indent > 0 ? "\n" : "",
+ end: list.indent > 0 ? "" : "\n"
};
}
@@ -84,11 +84,21 @@ function markdownWriter() {
function open(tagName, attributes) {
attributes = attributes || {};
+ var parentElementList = list;
+
+ if (isList(tagName)) {
+ list = {
+ type: tagName,
+ indent: list.indent + 1,
+ count: 0
+ };
+ }
+
var idHasBeenWritten = false;
var createElement = htmlmarkdown[tagName] || function() { return {}; };
var element = createElement(attributes, list);
- elementStack.push({end: element.end, list: list});
+ elementStack.push({end: element.end, list: parentElementList});
if (element.anchorPosition === "before") {
writeAnchor(attributes);
@@ -96,14 +106,6 @@ function markdownWriter() {
}
fragments.push(element.start || "");
-
- if (isList(tagName)) {
- list = {
- type: tagName,
- indent: list.indent + 1,
- count: 0
- };
- }
if (!idHasBeenWritten) {
writeAnchor(attributes);
}