mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
atx heading doesn't have to use regex
This commit is contained in:
parent
b9ab495cb4
commit
da966b83f1
@ -293,15 +293,20 @@ class Parsedown
|
||||
|
||||
# atx heading (#)
|
||||
|
||||
if (preg_match('/^(#{1,6})[ ]*(.+?)[ ]*#*$/', $line, $matches))
|
||||
if (isset($line[1]))
|
||||
{
|
||||
$elements []= $element;
|
||||
|
||||
$level = strlen($matches[1]);
|
||||
$level = 1;
|
||||
|
||||
while (isset($line[$level]) and $line[$level] === '#')
|
||||
{
|
||||
$level++;
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'type' => 'heading',
|
||||
'text' => $matches[2],
|
||||
'text' => trim($line, '# '),
|
||||
'level' => $level,
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user