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