Skip to content

Commit

Permalink
More efficient checking for loose lists.
Browse files Browse the repository at this point in the history
This fixes a case like commonmark/cmark#284.
  • Loading branch information
jgm committed Mar 18, 2019
1 parent cede389 commit 5181f25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ var endsWithBlankLine = function(block) {
return true;
}
var t = block.type;
if (t === 'list' || t === 'item') {
if (!block._lastLineChecked &&
(t === 'list' || t === 'item')) {
block._lastLineChecked = true;
block = block._lastChild;
} else {
block._lastLineChecked = true;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var Node = function(nodeType, sourcepos) {
this._next = null;
this._sourcepos = sourcepos;
this._lastLineBlank = false;
this._lastLineChecked = false;
this._open = true;
this._string_content = null;
this._literal = null;
Expand Down

0 comments on commit 5181f25

Please sign in to comment.