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:
parent
4367f89a74
commit
d7956e3ade
@ -683,7 +683,7 @@ class Parsedown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
|
if (preg_match('/^<[\/]?+(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
|
||||||
{
|
{
|
||||||
$element = strtolower($matches[1]);
|
$element = strtolower($matches[1]);
|
||||||
|
|
||||||
@ -694,7 +694,6 @@ class Parsedown
|
|||||||
|
|
||||||
$Block = array(
|
$Block = array(
|
||||||
'name' => $matches[1],
|
'name' => $matches[1],
|
||||||
'depth' => 0,
|
|
||||||
'markup' => $Line['text'],
|
'markup' => $Line['text'],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -730,35 +729,11 @@ class Parsedown
|
|||||||
|
|
||||||
protected function blockMarkupContinue($Line, array $Block)
|
protected function blockMarkupContinue($Line, array $Block)
|
||||||
{
|
{
|
||||||
if (isset($Block['closed']))
|
if (isset($Block['closed']) or isset($Block['interrupted']))
|
||||||
{
|
{
|
||||||
return;
|
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'];
|
$Block['markup'] .= "\n".$Line['body'];
|
||||||
|
|
||||||
return $Block;
|
return $Block;
|
||||||
|
Loading…
Reference in New Issue
Block a user