|
|
@ -98,43 +98,73 @@ function markTightParagraphs(state, idx) { |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
var nextLine, |
|
|
|
var ch, |
|
|
|
contentStart, |
|
|
|
i, |
|
|
|
indent, |
|
|
|
indentAfterMarker, |
|
|
|
initial, |
|
|
|
isOrdered, |
|
|
|
itemLines, |
|
|
|
l, |
|
|
|
listLines, |
|
|
|
listTokIdx, |
|
|
|
markerCharCode, |
|
|
|
markerValue, |
|
|
|
max, |
|
|
|
nextLine, |
|
|
|
offset, |
|
|
|
indent, |
|
|
|
oldTShift, |
|
|
|
oldIndent, |
|
|
|
oldLIndent, |
|
|
|
oldTight, |
|
|
|
oldParentType, |
|
|
|
start, |
|
|
|
posAfterMarker, |
|
|
|
ch, |
|
|
|
oldTShift, |
|
|
|
oldTight, |
|
|
|
pos, |
|
|
|
max, |
|
|
|
indentAfterMarker, |
|
|
|
markerValue, |
|
|
|
markerCharCode, |
|
|
|
isOrdered, |
|
|
|
contentStart, |
|
|
|
listTokIdx, |
|
|
|
posAfterMarker, |
|
|
|
prevEmptyEnd, |
|
|
|
listLines, |
|
|
|
itemLines, |
|
|
|
tight = true, |
|
|
|
start, |
|
|
|
terminate, |
|
|
|
terminatorRules, |
|
|
|
token, |
|
|
|
i, l, terminate; |
|
|
|
isTerminatingParagraph = false, |
|
|
|
tight = true; |
|
|
|
|
|
|
|
// limit conditions when list can interrupt
|
|
|
|
// a paragraph (validation mode only)
|
|
|
|
if (silent && state.parentType === 'paragraph') { |
|
|
|
// Next list item should still terminate previous list item;
|
|
|
|
//
|
|
|
|
// This code can fail if plugins use blkIndent as well as lists,
|
|
|
|
// but I hope the spec gets fixed long before that happens.
|
|
|
|
//
|
|
|
|
if (state.tShift[startLine] >= state.blkIndent) { |
|
|
|
isTerminatingParagraph = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Detect list type and position after marker
|
|
|
|
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { |
|
|
|
isOrdered = true; |
|
|
|
start = state.bMarks[startLine] + state.tShift[startLine]; |
|
|
|
markerValue = Number(state.src.substr(start, posAfterMarker - start - 1)); |
|
|
|
|
|
|
|
// If we're starting a new ordered list right after
|
|
|
|
// a paragraph, it should start with 1.
|
|
|
|
if (isTerminatingParagraph && markerValue !== 1) return false; |
|
|
|
|
|
|
|
} else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) { |
|
|
|
isOrdered = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// If we're starting a new unordered list right after
|
|
|
|
// a paragraph, first line should not be empty.
|
|
|
|
if (isTerminatingParagraph) { |
|
|
|
if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false; |
|
|
|
} |
|
|
|
|
|
|
|
// We should terminate list on style change. Remember first one to compare.
|
|
|
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1); |
|
|
|
|
|
|
@ -145,8 +175,6 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
|
listTokIdx = state.tokens.length; |
|
|
|
|
|
|
|
if (isOrdered) { |
|
|
|
start = state.bMarks[startLine] + state.tShift[startLine]; |
|
|
|
markerValue = Number(state.src.substr(start, posAfterMarker - start - 1)); |
|
|
|
token = state.push('ordered_list_open', 'ol', 1); |
|
|
|
if (markerValue !== 1) { |
|
|
|
token.attrs = [ [ 'start', markerValue ] ]; |
|
|
|