From a37797ef347a3777c284dc2e8f8058482b370c09 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Wed, 5 Oct 2016 18:15:47 +0100 Subject: [PATCH] Allow parsedown to specify list start attribute Syntax preferences to match surrounding code --- Parsedown.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 03b729b..3a5f0d2 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -503,6 +503,7 @@ class Parsedown protected function blockList($Line) { list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); + if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) { $Block = array( @@ -513,14 +514,16 @@ class Parsedown 'handler' => 'elements', ), ); + if($name === 'ol') { - $list_num = stristr($matches[0], ".", true); - if($list_num !== '1') + $listStart = stristr($matches[0], ".", true); + if($listStart !== '1') { - $Block['element']['attributes'] = array('start' => $list_num); + $Block['element']['attributes'] = array('start' => $listStart); } } + $Block['li'] = array( 'name' => 'li', 'handler' => 'li', @@ -528,7 +531,9 @@ class Parsedown $matches[2], ), ); + $Block['element']['text'] []= & $Block['li']; + return $Block; } }