From a3e02c1d0e7f7da041754328641a859e7a7be48a Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Wed, 28 Mar 2018 15:37:47 +0100 Subject: [PATCH 1/2] Add failing test case --- test/data/ordered_list.html | 5 ++++- test/data/ordered_list.md | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/data/ordered_list.html b/test/data/ordered_list.html index c4a69dbe6..b748fc184 100644 --- a/test/data/ordered_list.html +++ b/test/data/ordered_list.html @@ -10,4 +10,7 @@

large numbers:

  1. one
  2. -
\ No newline at end of file + +

foo 1. the following should not start a list +100.
+200.

\ No newline at end of file diff --git a/test/data/ordered_list.md b/test/data/ordered_list.md index b307032cf..d7e7fc1c9 100644 --- a/test/data/ordered_list.md +++ b/test/data/ordered_list.md @@ -8,4 +8,8 @@ repeating numbers: large numbers: -123. one \ No newline at end of file +123. one + +foo 1. the following should not start a list +100. +200. \ No newline at end of file From a9c21447cee7393bd20a4b26609ddbcb2ebf1332 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Wed, 28 Mar 2018 15:38:11 +0100 Subject: [PATCH 2/2] Only interrupt paragraph if starting with 1 --- Parsedown.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 11e50d5d4..5ca40d883 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -523,7 +523,7 @@ protected function blockHeader($Line) # # List - protected function blockList($Line) + protected function blockList($Line, array $CurrentBlock = null) { list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}[.\)]'); @@ -556,12 +556,20 @@ protected function blockList($Line) ), ); - if($name === 'ol') + if ($name === 'ol') { $listStart = ltrim(strstr($matches[1], $Block['data']['markerType'], true), '0') ?: '0'; - if($listStart !== '1') + if ($listStart !== '1') { + if ( + isset($CurrentBlock) + and ! isset($CurrentBlock['type']) + and ! isset($CurrentBlock['interrupted']) + ) { + return; + } + $Block['element']['attributes'] = array('start' => $listStart); } }