Browse Source

Add/fix indentation checking in blockquotes

fix #111
pull/124/head
Alex Kocharin 9 years ago
parent
commit
d292f72b69
  1. 4
      lib/rules_block/blockquote.js
  2. 3
      lib/rules_block/paragraph.js
  3. 3
      lib/rules_block/reference.js
  4. 24
      test/fixtures/markdown-it/commonmark_extras.txt

4
lib/rules_block/blockquote.js

@ -54,6 +54,8 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
// - - -
// ```
for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
if (state.tShift[nextLine] < oldIndent) { break; }
pos = state.bMarks[nextLine] + state.tShift[nextLine];
max = state.eMarks[nextLine];
@ -99,7 +101,7 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
//
// Any negative number will do the job here, but it's better for it
// to be large enough to make any bugs obvious.
state.tShift[nextLine] = -1337;
state.tShift[nextLine] = -1;
}
oldParentType = state.parentType;

3
lib/rules_block/paragraph.js

@ -15,6 +15,9 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
// it's considered a lazy continuation regardless of what's there
if (state.tShift[nextLine] - state.blkIndent > 3) { continue; }
// quirk for blockquotes, this line should already be checked by that rule
if (state.tShift[nextLine] < 0) { continue; }
// Some tags can terminate paragraph without empty line.
terminate = false;
for (i = 0, l = terminatorRules.length; i < l; i++) {

3
lib/rules_block/reference.js

@ -50,6 +50,9 @@ module.exports = function reference(state, startLine, _endLine, silent) {
// it's considered a lazy continuation regardless of what's there
if (state.tShift[nextLine] - state.blkIndent > 3) { continue; }
// quirk for blockquotes, this line should already be checked by that rule
if (state.tShift[nextLine] < 0) { continue; }
// Some tags can terminate paragraph without empty line.
terminate = false;
for (i = 0, l = terminatorRules.length; i < l; i++) {

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

@ -69,6 +69,23 @@ _(hai)_.
<p><em>(hai)</em>.</p>
.
Those are two separate blockquotes:
.
- > foo
> bar
.
<ul>
<li>
<blockquote>
<p>foo</p>
</blockquote>
</li>
</ul>
<blockquote>
<p>bar</p>
</blockquote>
.
Coverage. Directive can terminate paragraph.
.
@ -199,3 +216,10 @@ test
test
]</p>
.
.
> [foo]: bar
[foo]
.
<blockquote></blockquote>
<p><a href="bar">foo</a></p>
.

Loading…
Cancel
Save