Skip to content

Commit

Permalink
Fix handling of adjacent lists.
Browse files Browse the repository at this point in the history
An ordered list followed by an unordered list shouldn't be combined,
even in non-smartLists mode.

Should fix #530.
  • Loading branch information
kohler committed Nov 16, 2015
1 parent 88ce4df commit 4bbf9cc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/marked.js
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions test/new/adjacent_lists.html
@@ -0,0 +1,9 @@
<ul>
<li>This should be</li>
<li>An unordered list</li>
</ul>

<ol>
<li>This should be</li>
<li>An unordered list</li>
</ol>
5 changes: 5 additions & 0 deletions test/new/adjacent_lists.text
@@ -0,0 +1,5 @@
* This should be
* An unordered list

1. This should be
2. An unordered list
9 changes: 9 additions & 0 deletions test/tests/adjacent_lists.html
@@ -0,0 +1,9 @@
<ul>
<li>This should be</li>
<li>An unordered list</li>
</ul>

<ol>
<li>This should be</li>
<li>An unordered list</li>
</ol>
5 changes: 5 additions & 0 deletions test/tests/adjacent_lists.text
@@ -0,0 +1,5 @@
* This should be
* An unordered list

1. This should be
2. An unordered list

0 comments on commit 4bbf9cc

Please sign in to comment.