From 4bbf9cce54b0e6dd30db6028825a78270c7db6e7 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.text | 5 +++++ test/tests/adjacent_lists.html | 9 +++++++++ test/tests/adjacent_lists.text | 5 +++++ 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/new/adjacent_lists.html create mode 100644 test/new/adjacent_lists.text create mode 100644 test/tests/adjacent_lists.html create mode 100644 test/tests/adjacent_lists.text diff --git a/lib/marked.js b/lib/marked.js index 03251f3c58a..46500bc35bc 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -315,9 +315,10 @@ Lexer.prototype.token = function(src, top, bq) { // 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 00000000000..b4cd8f50863 --- /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.text b/test/new/adjacent_lists.text new file mode 100644 index 00000000000..3fd460b3d77 --- /dev/null +++ b/test/new/adjacent_lists.text @@ -0,0 +1,5 @@ +* This should be +* An unordered list + +1. This should be +2. An unordered list diff --git a/test/tests/adjacent_lists.html b/test/tests/adjacent_lists.html new file mode 100644 index 00000000000..b4cd8f50863 --- /dev/null +++ b/test/tests/adjacent_lists.html @@ -0,0 +1,9 @@ + + +
    +
  1. This should be
  2. +
  3. An unordered list
  4. +
diff --git a/test/tests/adjacent_lists.text b/test/tests/adjacent_lists.text new file mode 100644 index 00000000000..3fd460b3d77 --- /dev/null +++ b/test/tests/adjacent_lists.text @@ -0,0 +1,5 @@ +* This should be +* An unordered list + +1. This should be +2. An unordered list