1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Update Parsedown.php

Okay, so maybe I should have looked 20 lines or so above where I made the edit in the element function – looks like it already supports adding attributes ;p
Have amended the change to blocklist to use the already existing functionality, and have reverted the change that I made to the element function.
This commit is contained in:
Aidan Woods 2016-09-27 02:15:09 +01:00 committed by GitHub
parent 2cee8d8a2d
commit 38f4027d5e

View File

@ -505,7 +505,6 @@ class Parsedown
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 (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
{ {
if($name === 'ol' && $matches[2] !== '1') $name .= ' start="' . $matches[2] . '"';
$Block = array( $Block = array(
'indent' => $Line['indent'], 'indent' => $Line['indent'],
'pattern' => preg_replace('/\(|\)/', '', $pattern), 'pattern' => preg_replace('/\(|\)/', '', $pattern),
@ -514,6 +513,7 @@ class Parsedown
'handler' => 'elements', 'handler' => 'elements',
), ),
); );
if($name === 'ol' && $matches[2] !== '1') $Block['element']['attributes'] = array('start' => $matches[2]);
$Block['li'] = array( $Block['li'] = array(
'name' => 'li', 'name' => 'li',
'handler' => 'li', 'handler' => 'li',
@ -1416,7 +1416,7 @@ class Parsedown
$markup .= $Element['text']; $markup .= $Element['text'];
} }
$markup .= '</'.preg_replace('/[ ].*/', '', $Element['name']).'>'; $markup .= '</'.$Element['name']).'>';
} }
else else
{ {