diff options
author | Aidan Woods <aidantwoods@gmail.com> | 2016-10-05 18:15:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-05 18:15:47 +0100 |
commit | a37797ef347a3777c284dc2e8f8058482b370c09 (patch) | |
tree | a168d9e3c78970d435368e6e5f946b6814e98254 | |
parent | e3cd271f1603134c31359043677fbc8c7dc8d1e5 (diff) | |
download | parsedown-a37797ef347a3777c284dc2e8f8058482b370c09.zip parsedown-a37797ef347a3777c284dc2e8f8058482b370c09.tar.gz parsedown-a37797ef347a3777c284dc2e8f8058482b370c09.tar.bz2 |
Allow parsedown to specify list start attribute
Syntax preferences to match surrounding code
-rw-r--r-- | Parsedown.php | 11 |
1 files 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; } } |