|
@ -98,43 +98,73 @@ function markTightParagraphs(state, idx) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function list(state, startLine, endLine, silent) { |
|
|
module.exports = function list(state, startLine, endLine, silent) { |
|
|
var nextLine, |
|
|
var ch, |
|
|
|
|
|
contentStart, |
|
|
|
|
|
i, |
|
|
|
|
|
indent, |
|
|
|
|
|
indentAfterMarker, |
|
|
initial, |
|
|
initial, |
|
|
|
|
|
isOrdered, |
|
|
|
|
|
itemLines, |
|
|
|
|
|
l, |
|
|
|
|
|
listLines, |
|
|
|
|
|
listTokIdx, |
|
|
|
|
|
markerCharCode, |
|
|
|
|
|
markerValue, |
|
|
|
|
|
max, |
|
|
|
|
|
nextLine, |
|
|
offset, |
|
|
offset, |
|
|
indent, |
|
|
|
|
|
oldTShift, |
|
|
|
|
|
oldIndent, |
|
|
oldIndent, |
|
|
oldLIndent, |
|
|
oldLIndent, |
|
|
oldTight, |
|
|
|
|
|
oldParentType, |
|
|
oldParentType, |
|
|
start, |
|
|
oldTShift, |
|
|
posAfterMarker, |
|
|
oldTight, |
|
|
ch, |
|
|
|
|
|
pos, |
|
|
pos, |
|
|
max, |
|
|
posAfterMarker, |
|
|
indentAfterMarker, |
|
|
|
|
|
markerValue, |
|
|
|
|
|
markerCharCode, |
|
|
|
|
|
isOrdered, |
|
|
|
|
|
contentStart, |
|
|
|
|
|
listTokIdx, |
|
|
|
|
|
prevEmptyEnd, |
|
|
prevEmptyEnd, |
|
|
listLines, |
|
|
start, |
|
|
itemLines, |
|
|
terminate, |
|
|
tight = true, |
|
|
|
|
|
terminatorRules, |
|
|
terminatorRules, |
|
|
token, |
|
|
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
|
|
|
// Detect list type and position after marker
|
|
|
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { |
|
|
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) { |
|
|
isOrdered = true; |
|
|
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) { |
|
|
} else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) { |
|
|
isOrdered = false; |
|
|
isOrdered = false; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
return false; |
|
|
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.
|
|
|
// We should terminate list on style change. Remember first one to compare.
|
|
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1); |
|
|
markerCharCode = state.src.charCodeAt(posAfterMarker - 1); |
|
|
|
|
|
|
|
@ -145,8 +175,6 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
listTokIdx = state.tokens.length; |
|
|
listTokIdx = state.tokens.length; |
|
|
|
|
|
|
|
|
if (isOrdered) { |
|
|
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); |
|
|
token = state.push('ordered_list_open', 'ol', 1); |
|
|
if (markerValue !== 1) { |
|
|
if (markerValue !== 1) { |
|
|
token.attrs = [ [ 'start', markerValue ] ]; |
|
|
token.attrs = [ [ 'start', markerValue ] ]; |
|
|