diff options
author | Aidan Woods <aidantwoods@gmail.com> | 2016-09-27 00:53:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-27 00:53:51 +0100 |
commit | 2772b034c622e469684da29c7f36c51b8b6be7b0 (patch) | |
tree | 34eb64ff7915595bd1e01915084712ec75731451 | |
parent | a2ed1592bd064cf90661c266f7e89ea88c06b1db (diff) | |
download | parsedown-2772b034c622e469684da29c7f36c51b8b6be7b0.zip parsedown-2772b034c622e469684da29c7f36c51b8b6be7b0.tar.gz parsedown-2772b034c622e469684da29c7f36c51b8b6be7b0.tar.bz2 |
Update Parsedown.php
(I think this should work)
Allow parsedown to specify list start attribute (see: https://github.com/erusev/parsedown/issues/100#issuecomment-249729602)
-rw-r--r-- | Parsedown.php | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Parsedown.php b/Parsedown.php index 646af86..f0efdc5 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -502,10 +502,10 @@ class Parsedown protected function blockList($Line) { - list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); - + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '([*+-])') : array('ol', '([0-9]+)[.]'); if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) { + if($name === 'ol' && $matches[2] !== '1') $name. = ' start="' . $matches[2] . '"'; $Block = array( 'indent' => $Line['indent'], 'pattern' => $pattern, @@ -514,17 +514,14 @@ class Parsedown 'handler' => 'elements', ), ); - $Block['li'] = array( 'name' => 'li', 'handler' => 'li', 'text' => array( - $matches[2], + $matches[3], ), ); - $Block['element']['text'] []= & $Block['li']; - return $Block; } } @@ -1419,7 +1416,7 @@ class Parsedown $markup .= $Element['text']; } - $markup .= '</'.$Element['name'].'>'; + $markup .= '</'.preg_replace('/[ ].*/', '', $Element['name']).'>'; } else { |