1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

blockmarkup ends on interrupt by newline (CommonMark compliance)

This commit is contained in:
Aidan Woods 2017-03-25 14:28:43 +00:00
parent 4367f89a74
commit d7956e3ade
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -683,7 +683,7 @@ class Parsedown
return;
}
if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
if (preg_match('/^<[\/]?+(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
{
$element = strtolower($matches[1]);
@ -694,7 +694,6 @@ class Parsedown
$Block = array(
'name' => $matches[1],
'depth' => 0,
'markup' => $Line['text'],
);
@ -730,35 +729,11 @@ class Parsedown
protected function blockMarkupContinue($Line, array $Block)
{
if (isset($Block['closed']))
if (isset($Block['closed']) or isset($Block['interrupted']))
{
return;
}
if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
{
$Block['depth'] ++;
}
if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
{
if ($Block['depth'] > 0)
{
$Block['depth'] --;
}
else
{
$Block['closed'] = true;
}
}
if (isset($Block['interrupted']))
{
$Block['markup'] .= "\n";
unset($Block['interrupted']);
}
$Block['markup'] .= "\n".$Line['body'];
return $Block;