mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Allow parsedown to specify list start attribute
Syntax preferences to match surrounding code
This commit is contained in:
parent
e3cd271f16
commit
a37797ef34
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user