Browse Source

Fix blockquotes

```
>>> foo
> bar
>>> baz
```

this is now a single blockquote as per spec

close https://github.com/markdown-it/markdown-it/issues/696
pull/713/head
Alex Kocharin 4 years ago
parent
commit
b3531c876e
  1. 7
      lib/rules_block/blockquote.js
  2. 50
      test/fixtures/markdown-it/commonmark_extras.txt

7
lib/rules_block/blockquote.js

@ -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];
@ -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
//
@ -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];
@ -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

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

@ -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>
.

Loading…
Cancel
Save