diff --git a/CHANGELOG.md b/CHANGELOG.md index 694bae4..b88d9df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +8.3.2 / WIP +------------------ + +- Fix blockquote termination inside lists, #386. + + 8.3.1 / 2017-03-06 ------------------ diff --git a/lib/parser_block.js b/lib/parser_block.js index 97afabf..10505c7 100644 --- a/lib/parser_block.js +++ b/lib/parser_block.js @@ -15,7 +15,7 @@ var _rules = [ [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ], [ 'code', require('./rules_block/code') ], [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], - [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'list' ] ], + [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ], [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ], [ 'reference', require('./rules_block/reference') ], diff --git a/lib/rules_block/blockquote.js b/lib/rules_block/blockquote.js index 9283506..e41704d 100644 --- a/lib/rules_block/blockquote.js +++ b/lib/rules_block/blockquote.js @@ -10,7 +10,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { ch, i, initial, - isOutdented, l, lastLineEmpty, lines, @@ -26,6 +25,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { terminate, terminatorRules, token, + wasOutdented, oldLineMax = state.lineMax, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; @@ -106,6 +106,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { oldParentType = state.parentType; state.parentType = 'blockquote'; + wasOutdented = false; // Search the end of the block // @@ -134,7 +135,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { // > current blockquote // 2. checking this line // ``` - isOutdented = state.sCount[nextLine] < state.blkIndent; + if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true; pos = state.bMarks[nextLine] + state.tShift[nextLine]; max = state.eMarks[nextLine]; @@ -144,7 +145,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) { break; } - if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) { + if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) { // This line is inside the blockquote. // skip spaces after ">" and re-calculate offset @@ -244,8 +245,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { break; } - if (isOutdented) break; - oldBMarks.push(state.bMarks[nextLine]); oldBSCount.push(state.bsCount[nextLine]); oldTShift.push(state.tShift[nextLine]); diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 705c003..f84601a 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -100,6 +100,26 @@ Those are two separate blockquotes: . +Blockquote should terminate itself after paragraph continuation +. +- list + > blockquote +blockquote continuation + - next list item +. + +. + Regression test (code block + regular paragraph) . > foo