From 5181f25e5a6e006eb29c293150b9cfa365fbd6ba Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 17 Mar 2019 17:16:56 -0700 Subject: [PATCH] More efficient checking for loose lists. This fixes a case like commonmark/cmark#284. --- lib/blocks.js | 5 ++++- lib/node.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/blocks.js b/lib/blocks.js index 9c735f76..0c6a0295 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -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; } } diff --git a/lib/node.js b/lib/node.js index 4e2bd82a..a0f29be0 100644 --- a/lib/node.js +++ b/lib/node.js @@ -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;