Browse Source

Fix blockquote termination inside lists

close https://github.com/markdown-it/markdown-it/issues/386
pull/391/merge
Alex Kocharin 7 years ago
parent
commit
a733ffa8b6
  1. 6
      CHANGELOG.md
  2. 2
      lib/parser_block.js
  3. 9
      lib/rules_block/blockquote.js
  4. 20
      test/fixtures/markdown-it/commonmark_extras.txt

6
CHANGELOG.md

@ -1,3 +1,9 @@
8.3.2 / WIP
------------------
- Fix blockquote termination inside lists, #386.
8.3.1 / 2017-03-06
------------------

2
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') ],

9
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]);

20
test/fixtures/markdown-it/commonmark_extras.txt

@ -100,6 +100,26 @@ Those are two separate blockquotes:
</blockquote>
.
Blockquote should terminate itself after paragraph continuation
.
- list
> blockquote
blockquote continuation
- next list item
.
<ul>
<li>list
<blockquote>
<p>blockquote
blockquote continuation</p>
</blockquote>
<ul>
<li>next list item</li>
</ul>
</li>
</ul>
.
Regression test (code block + regular paragraph)
.
> foo

Loading…
Cancel
Save