Skip to content

Commit 58c8e75

Browse files
committed
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.
1 parent ed64407 commit 58c8e75

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

lib/marked.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ Lexer.prototype.token = function(src, top) {
355355

356356
// Determine whether the next list item belongs here.
357357
// Backpedal if it does not belong in this list.
358-
if (this.options.smartLists && i !== l - 1) {
358+
if (i !== l - 1) {
359359
b = block.bullet.exec(cap[i + 1])[0];
360-
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
360+
if (bull.length > 1 ? b.length == 1
361+
: (b.length > 1 || (this.options.smartLists && b !== bull))) {
361362
src = cap.slice(i + 1).join('\n') + src;
362363
i = l - 1;
363364
}

test/new/adjacent_lists.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ul>
2+
<li>This should be</li>
3+
<li>An unordered list</li>
4+
</ul>
5+
6+
<ol>
7+
<li>This should be</li>
8+
<li>An unordered list</li>
9+
</ol>

test/new/adjacent_lists.text

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* This should be
2+
* An unordered list
3+
4+
1. This should be
5+
2. An unordered list

test/tests/adjacent_lists.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ul>
2+
<li>This should be</li>
3+
<li>An unordered list</li>
4+
</ul>
5+
6+
<ol>
7+
<li>This should be</li>
8+
<li>An unordered list</li>
9+
</ol>

test/tests/adjacent_lists.text

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* This should be
2+
* An unordered list
3+
4+
1. This should be
5+
2. An unordered list

0 commit comments

Comments
 (0)