|
@ -10,6 +10,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
ch, |
|
|
ch, |
|
|
i, |
|
|
i, |
|
|
initial, |
|
|
initial, |
|
|
|
|
|
isOutdented, |
|
|
l, |
|
|
l, |
|
|
lastLineEmpty, |
|
|
lastLineEmpty, |
|
|
lines, |
|
|
lines, |
|
@ -25,9 +26,13 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
terminate, |
|
|
terminate, |
|
|
terminatorRules, |
|
|
terminatorRules, |
|
|
token, |
|
|
token, |
|
|
|
|
|
oldLineMax = state.lineMax, |
|
|
pos = state.bMarks[startLine] + state.tShift[startLine], |
|
|
pos = state.bMarks[startLine] + state.tShift[startLine], |
|
|
max = state.eMarks[startLine]; |
|
|
max = state.eMarks[startLine]; |
|
|
|
|
|
|
|
|
|
|
|
// if it's indented more than 3 spaces, it should be a code block
|
|
|
|
|
|
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; } |
|
|
|
|
|
|
|
|
// check the block quote marker
|
|
|
// check the block quote marker
|
|
|
if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; } |
|
|
if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; } |
|
|
|
|
|
|
|
@ -35,9 +40,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
// so no point trying to find the end of it in silent mode
|
|
|
// so no point trying to find the end of it in silent mode
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
|
|
|
state.blkIndent = 0; |
|
|
|
|
|
|
|
|
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
|
initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]); |
|
|
initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]); |
|
|
|
|
|
|
|
@ -118,13 +120,21 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
// >
|
|
|
// >
|
|
|
// test
|
|
|
// test
|
|
|
// ```
|
|
|
// ```
|
|
|
// 3. another tag
|
|
|
// 3. another tag:
|
|
|
// ```
|
|
|
// ```
|
|
|
// > test
|
|
|
// > test
|
|
|
// - - -
|
|
|
// - - -
|
|
|
// ```
|
|
|
// ```
|
|
|
for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { |
|
|
for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { |
|
|
if (state.sCount[nextLine] < oldIndent) { break; } |
|
|
// check if it's outdented, i.e. it's inside list item and indented
|
|
|
|
|
|
// less than said list item:
|
|
|
|
|
|
//
|
|
|
|
|
|
// ```
|
|
|
|
|
|
// 1. anything
|
|
|
|
|
|
// > current blockquote
|
|
|
|
|
|
// 2. checking this line
|
|
|
|
|
|
// ```
|
|
|
|
|
|
isOutdented = state.sCount[nextLine] < state.blkIndent; |
|
|
|
|
|
|
|
|
pos = state.bMarks[nextLine] + state.tShift[nextLine]; |
|
|
pos = state.bMarks[nextLine] + state.tShift[nextLine]; |
|
|
max = state.eMarks[nextLine]; |
|
|
max = state.eMarks[nextLine]; |
|
@ -134,7 +144,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */) { |
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) { |
|
|
// This line is inside the blockquote.
|
|
|
// This line is inside the blockquote.
|
|
|
|
|
|
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
@ -214,7 +224,13 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (terminate) { |
|
|
if (terminate) { |
|
|
if (oldIndent !== 0) { |
|
|
// Quirk to enforce "hard termination mode" for paragraphs;
|
|
|
|
|
|
// normally if you call `tokenize(state, startLine, nextLine)`,
|
|
|
|
|
|
// paragraphs will look below nextLine for paragraph continuation,
|
|
|
|
|
|
// but if blockquote is terminated by another tag, they shouldn't
|
|
|
|
|
|
state.lineMax = nextLine; |
|
|
|
|
|
|
|
|
|
|
|
if (state.blkIndent !== 0) { |
|
|
// state.blkIndent was non-zero, we now set it to zero,
|
|
|
// state.blkIndent was non-zero, we now set it to zero,
|
|
|
// so we need to re-calculate all offsets to appear as
|
|
|
// so we need to re-calculate all offsets to appear as
|
|
|
// if indent wasn't changed
|
|
|
// if indent wasn't changed
|
|
@ -222,12 +238,14 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
oldSCount.push(state.sCount[nextLine]); |
|
|
oldSCount.push(state.sCount[nextLine]); |
|
|
state.sCount[nextLine] -= oldIndent; |
|
|
state.sCount[nextLine] -= state.blkIndent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isOutdented) break; |
|
|
|
|
|
|
|
|
oldBMarks.push(state.bMarks[nextLine]); |
|
|
oldBMarks.push(state.bMarks[nextLine]); |
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
@ -238,6 +256,9 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
state.sCount[nextLine] = -1; |
|
|
state.sCount[nextLine] = -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
|
|
|
state.blkIndent = 0; |
|
|
|
|
|
|
|
|
token = state.push('blockquote_open', 'blockquote', 1); |
|
|
token = state.push('blockquote_open', 'blockquote', 1); |
|
|
token.markup = '>'; |
|
|
token.markup = '>'; |
|
|
token.map = lines = [ startLine, 0 ]; |
|
|
token.map = lines = [ startLine, 0 ]; |
|
@ -247,6 +268,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
token = state.push('blockquote_close', 'blockquote', -1); |
|
|
token = state.push('blockquote_close', 'blockquote', -1); |
|
|
token.markup = '>'; |
|
|
token.markup = '>'; |
|
|
|
|
|
|
|
|
|
|
|
state.lineMax = oldLineMax; |
|
|
state.parentType = oldParentType; |
|
|
state.parentType = oldParentType; |
|
|
lines[1] = state.line; |
|
|
lines[1] = state.line; |
|
|
|
|
|
|
|
|