dont cause errors

This commit is contained in:
Aidan Woods 2017-01-23 17:08:43 +00:00
parent fb3db195cb
commit 0d89b672d0
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -163,11 +163,14 @@ class Parsedown
# ~ # ~
$NewBlock = $this->block($Line, $CurrentBlock); if (isset($CurrentBlock))
if (isset($CurrentBlock['indent']) and isset($NewBlock) and $NewBlock['indent'] < $CurrentBlock['indent'])
{ {
$CurrentBlock['interrupted'] = true; $NewBlock = $this->block($Line, $CurrentBlock);
if (isset($CurrentBlock['indent']) and isset($NewBlock) and $NewBlock['indent'] < $CurrentBlock['indent'])
{
$CurrentBlock['interrupted'] = true;
}
} }
# ~ # ~
@ -209,6 +212,7 @@ class Parsedown
continue; continue;
} }
# ~ # ~
if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
@ -323,11 +327,9 @@ class Parsedown
$Block['indent'] = $Line['indent']; $Block['indent'] = $Line['indent'];
} }
continue; return $Block;
} }
} }
return $Block;
} }
# #
@ -546,11 +548,13 @@ class Parsedown
{ {
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) if (preg_match('/^('.$pattern.')([ ]+)(.*)/', $Line['text'], $matches))
{ {
$markerWhitespace = strlen($matches[1]); $markerLength = strlen($matches[1]);
$indent = $Line['indent'] + $markerWhitespace; $markerWhitespace = strlen($matches[2]);
$indent = $Line['indent'] + $markerLength + $markerWhitespace;
$Block = array( $Block = array(
'indent' => $indent, 'indent' => $indent,
@ -576,7 +580,7 @@ class Parsedown
'name' => 'li', 'name' => 'li',
'handler' => 'li', 'handler' => 'li',
'text' => array( 'text' => array(
$matches[2], $matches[3],
), ),
); );
@ -590,8 +594,6 @@ class Parsedown
{ {
if (preg_match('/^('.$Block['pattern'].')(?:[ ]+(.*)|$)/', $Line['text'], $matches)) if (preg_match('/^('.$Block['pattern'].')(?:[ ]+(.*)|$)/', $Line['text'], $matches))
{ {
$text = isset($matches[2]) ? $matches[2] : '';
if (isset($Block['markerWhitespace'])) if (isset($Block['markerWhitespace']))
{ {
$Line['indent'] += strlen($matches[1]) + $Block['markerWhitespace']; $Line['indent'] += strlen($matches[1]) + $Block['markerWhitespace'];
@ -599,29 +601,29 @@ class Parsedown
if ($Block['indent'] === $Line['indent']) if ($Block['indent'] === $Line['indent'])
{ {
return; if (isset($Block['interrupted']))
{
$Block['li']['text'] []= '';
unset($Block['interrupted']);
}
unset($Block['li']);
$text = isset($matches[2]) ? $matches[2] : '';
$Block['li'] = array(
'name' => 'li',
'handler' => 'li',
'text' => array(
$text,
),
);
$Block['element']['text'] []= & $Block['li'];
return $Block;
} }
if (isset($Block['interrupted']))
{
$Block['li']['text'] []= '';
unset($Block['interrupted']);
}
unset($Block['li']);
$Block['li'] = array(
'name' => 'li',
'handler' => 'li',
'text' => array(
$text,
),
);
$Block['element']['text'] []= & $Block['li'];
return $Block;
} }
if ($Line['text'][0] === '[' and $this->blockReference($Line)) if ($Line['text'][0] === '[' and $this->blockReference($Line))