|
|
@ -85,11 +85,12 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
max, |
|
|
|
indentAfterMarker, |
|
|
|
markerValue, |
|
|
|
markerCharCode, |
|
|
|
isOrdered, |
|
|
|
contentStart, |
|
|
|
listTokIdx, |
|
|
|
endOfList; |
|
|
|
//rules_named = state.lexerBlock.rules_named;
|
|
|
|
prevEmptyEnd, |
|
|
|
rules_named = state.lexerBlock.rules_named; |
|
|
|
|
|
|
|
// Detect list type and position after marker
|
|
|
|
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { |
|
|
@ -99,6 +100,8 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
// We should terminate list on style change. Remember first one to compare.
|
|
|
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1); |
|
|
|
|
|
|
|
// For validation mode we can terminate immediately
|
|
|
|
if (silent) { return true; } |
|
|
@ -128,18 +131,9 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
//
|
|
|
|
|
|
|
|
nextLine = startLine; |
|
|
|
endOfList = false; |
|
|
|
|
|
|
|
while (nextLine < endLine && !endOfList) { |
|
|
|
if (state.tShift[startLine] < state.blkIndent) { return -1; } |
|
|
|
if (isOrdered) { |
|
|
|
posAfterMarker = skipOrderedListMarker(state, nextLine); |
|
|
|
if (posAfterMarker < 0) { break; } |
|
|
|
} else { |
|
|
|
posAfterMarker = skipBulletListMarker(state, nextLine); |
|
|
|
if (posAfterMarker < 0) { break; } |
|
|
|
} |
|
|
|
prevEmptyEnd = false; |
|
|
|
|
|
|
|
while (nextLine < endLine) { |
|
|
|
contentStart = skipSpaces(state, posAfterMarker); |
|
|
|
max = state.eMarks[nextLine]; |
|
|
|
|
|
|
@ -165,18 +159,22 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
// Run sublexer & write tokens
|
|
|
|
state.tokens.push({ type: 'list_item_open' }); |
|
|
|
|
|
|
|
nextLine++; |
|
|
|
//nextLine++;
|
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
|
oldTight = state.tight; |
|
|
|
state.blkIndent = state.tShift[startLine] = indent; |
|
|
|
state.tight = true; |
|
|
|
|
|
|
|
state.lexerBlock.tokenize(state, startLine, endLine, true); |
|
|
|
|
|
|
|
// If any of list item is loose, mark list as loose
|
|
|
|
if (!state.tight || isEmpty(state, state.line - 1)) { |
|
|
|
// If any of list item is tight, mark list as tight
|
|
|
|
if (!state.tight || prevEmptyEnd) { |
|
|
|
state.tokens[listTokIdx].tight = false; |
|
|
|
} |
|
|
|
// Item become loose if finish with empty line,
|
|
|
|
// but we should filter last element, because it means list finish
|
|
|
|
prevEmptyEnd = (state.line - startLine) > 1 && isEmpty(state, state.line - 1); |
|
|
|
|
|
|
|
state.blkIndent = state.tShift[startLine] = oldIndent; |
|
|
|
state.tight = oldTight; |
|
|
@ -195,6 +193,28 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//
|
|
|
|
// Try to ckeck if list is terminated or continued.
|
|
|
|
//
|
|
|
|
|
|
|
|
// fail if terminating block found
|
|
|
|
if (rules_named.fences(state, nextLine, endLine, true)) { break; } |
|
|
|
if (rules_named.blockquote(state, nextLine, endLine, true)) { break; } |
|
|
|
if (rules_named.hr(state, nextLine, endLine, true)) { break; } |
|
|
|
|
|
|
|
// fail if list has another type
|
|
|
|
if (isOrdered) { |
|
|
|
posAfterMarker = skipOrderedListMarker(state, nextLine); |
|
|
|
if (posAfterMarker < 0) { break; } |
|
|
|
} else { |
|
|
|
posAfterMarker = skipBulletListMarker(state, nextLine); |
|
|
|
if (posAfterMarker < 0) { break; } |
|
|
|
} |
|
|
|
|
|
|
|
if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; } |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Finilize list
|
|
|
|