From 0e1043a8d6bb5bae93bfc65c99bd109e7f486b7b Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 19 Feb 2017 16:12:04 +0000 Subject: [PATCH 1/3] consistent li items for loose list --- Parsedown.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 757666e00..877f5b863 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -515,10 +515,10 @@ protected function blockList($Line) ), ); - if($name === 'ol') + if($name === 'ol') { $listStart = stristr($matches[0], '.', true); - + if($listStart !== '1') { $Block['element']['attributes'] = array('start' => $listStart); @@ -547,6 +547,8 @@ protected function blockListContinue($Line, array $Block) { $Block['li']['text'] []= ''; + $Block['loose'] = true; + unset($Block['interrupted']); } @@ -595,6 +597,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 From 7fd92a8fbd76dc9312dc7fb47fe05c8fb02fe3b7 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 19 Feb 2017 16:19:55 +0000 Subject: [PATCH 2/3] update tests --- test/data/paragraph_list.html | 4 +++- test/data/sparse_dense_list.html | 8 ++++++-- test/data/sparse_list.html | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/data/paragraph_list.html b/test/data/paragraph_list.html index ced1c43ee..00a612c13 100644 --- a/test/data/paragraph_list.html +++ b/test/data/paragraph_list.html @@ -8,5 +8,7 @@
  • li

  • -
  • li
  • +
  • +

    li

    +
  • \ No newline at end of file diff --git a/test/data/sparse_dense_list.html b/test/data/sparse_dense_list.html index 095bc7396..58923f8a1 100644 --- a/test/data/sparse_dense_list.html +++ b/test/data/sparse_dense_list.html @@ -2,6 +2,10 @@
  • li

  • -
  • li
  • -
  • li
  • +
  • +

    li

    +
  • +
  • +

    li

    +
  • \ No newline at end of file diff --git a/test/data/sparse_list.html b/test/data/sparse_list.html index 452b2b86d..9803d27cd 100644 --- a/test/data/sparse_list.html +++ b/test/data/sparse_list.html @@ -2,7 +2,9 @@
  • li

  • -
  • li
  • +
  • +

    li

    +