mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
check the validity of heading
This commit is contained in:
parent
d29ff18299
commit
d3713588ae
@ -277,18 +277,31 @@ class Parsedown
|
||||
|
||||
if (isset($line[1]))
|
||||
{
|
||||
$blocks []= $block;
|
||||
|
||||
$level = 1;
|
||||
|
||||
while (isset($line[$level]) and $line[$level] === '#')
|
||||
while (isset($line[$level]) and $level < 7 and $line[$level] === '#')
|
||||
{
|
||||
$level++;
|
||||
}
|
||||
|
||||
# check heading level
|
||||
if ($level == 7)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$heading = trim($line, '# ');
|
||||
# check heading text
|
||||
if ( ! isset($heading[0]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$blocks []= $block;
|
||||
|
||||
$block = array(
|
||||
'type' => 'heading',
|
||||
'text' => trim($line, '# '),
|
||||
'text' => $heading,
|
||||
'level' => $level,
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user