1
0
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:
Emanuil Rusev 2014-01-17 00:36:11 +02:00
parent b9ab495cb4
commit da966b83f1

View File

@ -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,
);