Skip to content

Commit

Permalink
Merge pull request #684 from kohler/adjacentlists
Browse files Browse the repository at this point in the history
Fix handling of adjacent lists.
  • Loading branch information
styfle authored Dec 10, 2018
2 parents c11bb3e + a48a9f0 commit 2d94bf3
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 2d94bf3

Please sign in to comment.