|
|
@ -10,6 +10,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
ch, |
|
|
|
i, |
|
|
|
initial, |
|
|
|
isOutdented, |
|
|
|
l, |
|
|
|
lastLineEmpty, |
|
|
|
lines, |
|
|
@ -25,9 +26,13 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
terminate, |
|
|
|
terminatorRules, |
|
|
|
token, |
|
|
|
oldLineMax = state.lineMax, |
|
|
|
pos = state.bMarks[startLine] + state.tShift[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
|
|
|
|
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
|
|
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
|
state.blkIndent = 0; |
|
|
|
|
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
|
|
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
|
|
|
|
// ```
|
|
|
|
// 3. another tag
|
|
|
|
// 3. another tag:
|
|
|
|
// ```
|
|
|
|
// > test
|
|
|
|
// - - -
|
|
|
|
// ```
|
|
|
|
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]; |
|
|
|
max = state.eMarks[nextLine]; |
|
|
@ -134,7 +144,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */) { |
|
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) { |
|
|
|
// This line is inside the blockquote.
|
|
|
|
|
|
|
|
// skip spaces after ">" and re-calculate offset
|
|
|
@ -214,7 +224,13 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
} |
|
|
|
|
|
|
|
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,
|
|
|
|
// so we need to re-calculate all offsets to appear as
|
|
|
|
// if indent wasn't changed
|
|
|
@ -222,12 +238,14 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
|
oldSCount.push(state.sCount[nextLine]); |
|
|
|
state.sCount[nextLine] -= oldIndent; |
|
|
|
state.sCount[nextLine] -= state.blkIndent; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (isOutdented) break; |
|
|
|
|
|
|
|
oldBMarks.push(state.bMarks[nextLine]); |
|
|
|
oldBSCount.push(state.bsCount[nextLine]); |
|
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
@ -238,6 +256,9 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
state.sCount[nextLine] = -1; |
|
|
|
} |
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
|
state.blkIndent = 0; |
|
|
|
|
|
|
|
token = state.push('blockquote_open', 'blockquote', 1); |
|
|
|
token.markup = '>'; |
|
|
|
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.markup = '>'; |
|
|
|
|
|
|
|
state.lineMax = oldLineMax; |
|
|
|
state.parentType = oldParentType; |
|
|
|
lines[1] = state.line; |
|
|
|
|
|
|
|