diff --git a/Parsedown.php b/Parsedown.php index 11e50d5..5ca40d8 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -523,7 +523,7 @@ class Parsedown # # 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 @@ class Parsedown ), ); - 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); } } diff --git a/test/data/ordered_list.html b/test/data/ordered_list.html index c4a69db..b748fc1 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 b307032..d7e7fc1 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