Skip to content

Commit

Permalink
Merge pull request #475 from aidantwoods/loose-lists
Browse files Browse the repository at this point in the history
Loose lists
  • Loading branch information
aidantwoods committed Feb 28, 2018
2 parents 6678d59 + 722b776 commit 5057e50
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
18 changes: 18 additions & 0 deletions Parsedown.php
Expand Up @@ -569,6 +569,8 @@ protected function blockListContinue($Line, array $Block)
{
$Block['li']['text'] []= '';

$Block['loose'] = true;

unset($Block['interrupted']);
}

Expand Down Expand Up @@ -617,6 +619,22 @@ protected function blockListContinue($Line, array $Block)
}
}

protected function blockListComplete(array $Block)
{
if (isset($Block['loose']))
{
foreach ($Block['element']['text'] as &$li)
{
if (end($li['text']) !== '')
{
$li['text'] []= '';
}
}
}

return $Block;
}

#
# Quote

Expand Down
10 changes: 10 additions & 0 deletions test/data/multiline_lists.html
@@ -0,0 +1,10 @@
<ol>
<li>
<p>One
First body copy</p>
</li>
<li>
<p>Two
Last body copy</p>
</li>
</ol>
5 changes: 5 additions & 0 deletions test/data/multiline_lists.md
@@ -0,0 +1,5 @@
1. One
First body copy

2. Two
Last body copy
4 changes: 3 additions & 1 deletion test/data/paragraph_list.html
Expand Up @@ -8,5 +8,7 @@
<li>
<p>li</p>
</li>
<li>li</li>
<li>
<p>li</p>
</li>
</ul>
8 changes: 6 additions & 2 deletions test/data/sparse_dense_list.html
Expand Up @@ -2,6 +2,10 @@
<li>
<p>li</p>
</li>
<li>li</li>
<li>li</li>
<li>
<p>li</p>
</li>
<li>
<p>li</p>
</li>
</ul>
4 changes: 3 additions & 1 deletion test/data/sparse_list.html
Expand Up @@ -2,7 +2,9 @@
<li>
<p>li</p>
</li>
<li>li</li>
<li>
<p>li</p>
</li>
</ul>
<hr />
<ul>
Expand Down

0 comments on commit 5057e50

Please sign in to comment.