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,12 +163,15 @@ class Parsedown
# ~ # ~
if (isset($CurrentBlock))
{
$NewBlock = $this->block($Line, $CurrentBlock); $NewBlock = $this->block($Line, $CurrentBlock);
if (isset($CurrentBlock['indent']) and isset($NewBlock) and $NewBlock['indent'] < $CurrentBlock['indent']) if (isset($CurrentBlock['indent']) and isset($NewBlock) and $NewBlock['indent'] < $CurrentBlock['indent'])
{ {
$CurrentBlock['interrupted'] = true; $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,12 +327,10 @@ class Parsedown
$Block['indent'] = $Line['indent']; $Block['indent'] = $Line['indent'];
} }
continue;
}
}
return $Block; return $Block;
} }
}
}
# #
# Code # Code
@ -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,9 +601,6 @@ class Parsedown
if ($Block['indent'] === $Line['indent']) if ($Block['indent'] === $Line['indent'])
{ {
return;
}
if (isset($Block['interrupted'])) if (isset($Block['interrupted']))
{ {
$Block['li']['text'] []= ''; $Block['li']['text'] []= '';
@ -611,6 +610,8 @@ class Parsedown
unset($Block['li']); unset($Block['li']);
$text = isset($matches[2]) ? $matches[2] : '';
$Block['li'] = array( $Block['li'] = array(
'name' => 'li', 'name' => 'li',
'handler' => 'li', 'handler' => 'li',
@ -623,6 +624,7 @@ class Parsedown
return $Block; return $Block;
} }
}
if ($Line['text'][0] === '[' and $this->blockReference($Line)) if ($Line['text'][0] === '[' and $this->blockReference($Line))
{ {