|
|
@ -88,7 +88,9 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
prevEmptyEnd, |
|
|
|
listLines, |
|
|
|
itemLines, |
|
|
|
terminatorRules = state.parser._rulesListTerm, i, l, terminate; |
|
|
|
tight = true, |
|
|
|
terminatorRules = state.parser._rulesListTerm, |
|
|
|
i, l, terminate, level, tokens; |
|
|
|
|
|
|
|
// Detect list type and position after marker
|
|
|
|
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { |
|
|
@ -117,7 +119,6 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
state.tokens.push({ |
|
|
|
type: 'ordered_list_open', |
|
|
|
order: markerValue, |
|
|
|
tight: true, |
|
|
|
lines: listLines = [ startLine, 0 ], |
|
|
|
level: state.level++ |
|
|
|
}); |
|
|
@ -125,7 +126,6 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
} else { |
|
|
|
state.tokens.push({ |
|
|
|
type: 'bullet_list_open', |
|
|
|
tight: true, |
|
|
|
lines: listLines = [ startLine, 0 ], |
|
|
|
level: state.level++ |
|
|
|
}); |
|
|
@ -183,7 +183,7 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
// If any of list item is tight, mark list as tight
|
|
|
|
if (!state.tight || prevEmptyEnd) { |
|
|
|
state.tokens[listTokIdx].tight = false; |
|
|
|
tight = false; |
|
|
|
} |
|
|
|
// Item become loose if finish with empty line,
|
|
|
|
// but we should filter last element, because it means list finish
|
|
|
@ -194,7 +194,10 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
state.tight = oldTight; |
|
|
|
state.parentType = oldParentType; |
|
|
|
|
|
|
|
state.tokens.push({ type: 'list_item_close', level: --state.level }); |
|
|
|
state.tokens.push({ |
|
|
|
type: 'list_item_close', |
|
|
|
level: --state.level |
|
|
|
}); |
|
|
|
|
|
|
|
nextLine = startLine = state.line; |
|
|
|
itemLines[1] = nextLine; |
|
|
@ -234,13 +237,27 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
} |
|
|
|
|
|
|
|
// Finilize list
|
|
|
|
if (isOrdered) { |
|
|
|
state.tokens.push({ type: 'ordered_list_close', level: --state.level }); |
|
|
|
} else { |
|
|
|
state.tokens.push({ type: 'bullet_list_close', level: --state.level }); |
|
|
|
} |
|
|
|
state.tokens.push({ |
|
|
|
type: isOrdered ? 'ordered_list_close' : 'bullet_list_close', |
|
|
|
level: --state.level |
|
|
|
}); |
|
|
|
listLines[1] = nextLine; |
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
|
|
|
|
|
// mark paragraphs tight if needed
|
|
|
|
if (tight) { |
|
|
|
level = state.level + 2; |
|
|
|
tokens = state.tokens; |
|
|
|
|
|
|
|
for (i = listTokIdx + 2, l = tokens.length - 2; i < l; i++) { |
|
|
|
if (tokens[i].level === level && tokens[i].type === 'paragraph_open') { |
|
|
|
tokens[i].tight = true; |
|
|
|
i += 2; |
|
|
|
tokens[i].tight = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}; |
|
|
|