Skip to content

Commit

Permalink
Fix blockquote termination inside lists
Browse files Browse the repository at this point in the history
close #386
  • Loading branch information
rlidwka committed Aug 3, 2017
1 parent c4d0a7f commit a733ffa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
8.3.2 / WIP
------------------

- Fix blockquote termination inside lists, #386.


8.3.1 / 2017-03-06
------------------

Expand Down
2 changes: 1 addition & 1 deletion lib/parser_block.js
Expand Up @@ -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') ],
Expand Down
9 changes: 4 additions & 5 deletions lib/rules_block/blockquote.js
Expand Up @@ -10,7 +10,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
ch,
i,
initial,
isOutdented,
l,
lastLineEmpty,
lines,
Expand All @@ -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];
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down Expand Up @@ -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]);
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/markdown-it/commonmark_extras.txt
Expand Up @@ -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
Expand Down

0 comments on commit a733ffa

Please sign in to comment.