mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 12:01: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]))
|
if (isset($line[1]))
|
||||||
{
|
{
|
||||||
$blocks []= $block;
|
|
||||||
|
|
||||||
$level = 1;
|
$level = 1;
|
||||||
|
|
||||||
while (isset($line[$level]) and $line[$level] === '#')
|
while (isset($line[$level]) and $level < 7 and $line[$level] === '#')
|
||||||
{
|
{
|
||||||
$level++;
|
$level++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check heading level
|
||||||
|
if ($level == 7)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$heading = trim($line, '# ');
|
||||||
|
# check heading text
|
||||||
|
if ( ! isset($heading[0]))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocks []= $block;
|
||||||
|
|
||||||
$block = array(
|
$block = array(
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'text' => trim($line, '# '),
|
'text' => $heading,
|
||||||
'level' => $level,
|
'level' => $level,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user