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 Dec 10, 2018
1 parent 86214bb commit a48a9f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions test/new/adjacent_lists.html
Original file line number Diff line number Diff line change
@@ -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.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* This should be
* An unordered list

1. This should be
2. An unordered list

0 comments on commit a48a9f0

Please sign in to comment.