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
1 changed files with 8 additions and 3 deletions

View File

@ -293,15 +293,20 @@ class Parsedown
# atx heading (#) # atx heading (#)
if (preg_match('/^(#{1,6})[ ]*(.+?)[ ]*#*$/', $line, $matches)) if (isset($line[1]))
{ {
$elements []= $element; $elements []= $element;
$level = strlen($matches[1]); $level = 1;
while (isset($line[$level]) and $line[$level] === '#')
{
$level++;
}
$element = array( $element = array(
'type' => 'heading', 'type' => 'heading',
'text' => $matches[2], 'text' => trim($line, '# '),
'level' => $level, 'level' => $level,
); );