From a48a9f0fc40a5aa21e37d4657f494e0e5ec10438 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Mon, 16 Nov 2015 18:41:47 -0500 Subject: [PATCH] Fix handling of adjacent lists. An ordered list followed by an unordered list shouldn't be combined, even in non-smartLists mode. Should fix #530. --- lib/marked.js | 5 +++-- test/new/adjacent_lists.html | 9 +++++++++ test/new/adjacent_lists.md | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/new/adjacent_lists.html create mode 100644 test/new/adjacent_lists.md diff --git a/lib/marked.js b/lib/marked.js index 47da4f52b6..4605feeebf 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -355,9 +355,10 @@ Lexer.prototype.token = function(src, top) { // Determine whether the next list item belongs here. // Backpedal if it does not belong in this list. - if (this.options.smartLists && i !== l - 1) { + if (i !== l - 1) { b = block.bullet.exec(cap[i + 1])[0]; - if (bull !== b && !(bull.length > 1 && b.length > 1)) { + if (bull.length > 1 ? b.length === 1 + : (b.length > 1 || (this.options.smartLists && b !== bull))) { src = cap.slice(i + 1).join('\n') + src; i = l - 1; } diff --git a/test/new/adjacent_lists.html b/test/new/adjacent_lists.html new file mode 100644 index 0000000000..b4cd8f5086 --- /dev/null +++ b/test/new/adjacent_lists.html @@ -0,0 +1,9 @@ + + +
    +
  1. This should be
  2. +
  3. An unordered list
  4. +
diff --git a/test/new/adjacent_lists.md b/test/new/adjacent_lists.md new file mode 100644 index 0000000000..3fd460b3d7 --- /dev/null +++ b/test/new/adjacent_lists.md @@ -0,0 +1,5 @@ +* This should be +* An unordered list + +1. This should be +2. An unordered list