Skip to content

Commit

Permalink
Fix blockquotes
Browse files Browse the repository at this point in the history
```
>>> foo
> bar
>>> baz
```

this is now a single blockquote as per spec

close #696
  • Loading branch information
rlidwka committed Sep 10, 2020
1 parent 144e5fa commit b3531c8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/rules_block/blockquote.js
Expand Up @@ -25,7 +25,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
terminate,
terminatorRules,
token,
wasOutdented,
isOutdented,
oldLineMax = state.lineMax,
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
Expand Down Expand Up @@ -106,7 +106,6 @@ 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 @@ -135,7 +134,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
// > current blockquote
// 2. checking this line
// ```
if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true;
isOutdented = state.sCount[nextLine] < state.blkIndent;

pos = state.bMarks[nextLine] + state.tShift[nextLine];
max = state.eMarks[nextLine];
Expand All @@ -145,7 +144,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
break;
}

if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) {
if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !isOutdented) {
// This line is inside the blockquote.

// skip spaces after ">" and re-calculate offset
Expand Down
50 changes: 50 additions & 0 deletions test/fixtures/markdown-it/commonmark_extras.txt
Expand Up @@ -522,3 +522,53 @@ Coverage, entities with code > 10FFFF. Made this way for compatibility with comm
<p>�</p>
<p>&amp;#x1100000;</p>
.

Issue #696. Blockquotes should remember their level.
.
>>> foo
bar
>>> baz
.
<blockquote>
<blockquote>
<blockquote>
<p>foo
bar
baz</p>
</blockquote>
</blockquote>
</blockquote>
.

Issue #696. Blockquotes should stop when outdented from a list.
.
1. >>> foo
bar
baz
>>> foo
>>> bar
>>> baz
.
<ol>
<li>
<blockquote>
<blockquote>
<blockquote>
<p>foo
bar
baz
foo</p>
</blockquote>
</blockquote>
</blockquote>
</li>
</ol>
<blockquote>
<blockquote>
<blockquote>
<p>bar
baz</p>
</blockquote>
</blockquote>
</blockquote>
.

0 comments on commit b3531c8

Please sign in to comment.