|
@ -85,11 +85,12 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
max, |
|
|
max, |
|
|
indentAfterMarker, |
|
|
indentAfterMarker, |
|
|
markerValue, |
|
|
markerValue, |
|
|
|
|
|
markerCharCode, |
|
|
isOrdered, |
|
|
isOrdered, |
|
|
contentStart, |
|
|
contentStart, |
|
|
listTokIdx, |
|
|
listTokIdx, |
|
|
endOfList; |
|
|
prevEmptyEnd, |
|
|
//rules_named = state.lexerBlock.rules_named;
|
|
|
rules_named = state.lexerBlock.rules_named; |
|
|
|
|
|
|
|
|
// 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) { |
|
@ -99,6 +100,8 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
} else { |
|
|
} else { |
|
|
return false; |
|
|
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
|
|
|
// For validation mode we can terminate immediately
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
@ -128,18 +131,9 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
//
|
|
|
//
|
|
|
|
|
|
|
|
|
nextLine = startLine; |
|
|
nextLine = startLine; |
|
|
endOfList = false; |
|
|
prevEmptyEnd = 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; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (nextLine < endLine) { |
|
|
contentStart = skipSpaces(state, posAfterMarker); |
|
|
contentStart = skipSpaces(state, posAfterMarker); |
|
|
max = state.eMarks[nextLine]; |
|
|
max = state.eMarks[nextLine]; |
|
|
|
|
|
|
|
@ -165,18 +159,22 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
// Run sublexer & write tokens
|
|
|
// Run sublexer & write tokens
|
|
|
state.tokens.push({ type: 'list_item_open' }); |
|
|
state.tokens.push({ type: 'list_item_open' }); |
|
|
|
|
|
|
|
|
nextLine++; |
|
|
//nextLine++;
|
|
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
oldIndent = state.blkIndent; |
|
|
oldTight = state.tight; |
|
|
oldTight = state.tight; |
|
|
state.blkIndent = state.tShift[startLine] = indent; |
|
|
state.blkIndent = state.tShift[startLine] = indent; |
|
|
|
|
|
state.tight = true; |
|
|
|
|
|
|
|
|
state.lexerBlock.tokenize(state, startLine, endLine, true); |
|
|
state.lexerBlock.tokenize(state, startLine, endLine, true); |
|
|
|
|
|
|
|
|
// If any of list item is loose, mark list as loose
|
|
|
// If any of list item is tight, mark list as tight
|
|
|
if (!state.tight || isEmpty(state, state.line - 1)) { |
|
|
if (!state.tight || prevEmptyEnd) { |
|
|
state.tokens[listTokIdx].tight = false; |
|
|
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.blkIndent = state.tShift[startLine] = oldIndent; |
|
|
state.tight = oldTight; |
|
|
state.tight = oldTight; |
|
@ -195,6 +193,28 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
break; |
|
|
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
|
|
|
// Finilize list
|
|
|