mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 12:01:29 +02:00
dont cause errors
This commit is contained in:
parent
fb3db195cb
commit
0d89b672d0
@ -163,12 +163,15 @@ class Parsedown
|
||||
|
||||
# ~
|
||||
|
||||
if (isset($CurrentBlock))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
# ~
|
||||
|
||||
if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
|
||||
@ -323,12 +327,10 @@ class Parsedown
|
||||
$Block['indent'] = $Line['indent'];
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Code
|
||||
@ -546,11 +548,13 @@ class Parsedown
|
||||
{
|
||||
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(
|
||||
'indent' => $indent,
|
||||
@ -576,7 +580,7 @@ class Parsedown
|
||||
'name' => 'li',
|
||||
'handler' => 'li',
|
||||
'text' => array(
|
||||
$matches[2],
|
||||
$matches[3],
|
||||
),
|
||||
);
|
||||
|
||||
@ -590,8 +594,6 @@ class Parsedown
|
||||
{
|
||||
if (preg_match('/^('.$Block['pattern'].')(?:[ ]+(.*)|$)/', $Line['text'], $matches))
|
||||
{
|
||||
$text = isset($matches[2]) ? $matches[2] : '';
|
||||
|
||||
if (isset($Block['markerWhitespace']))
|
||||
{
|
||||
$Line['indent'] += strlen($matches[1]) + $Block['markerWhitespace'];
|
||||
@ -599,9 +601,6 @@ class Parsedown
|
||||
|
||||
if ($Block['indent'] === $Line['indent'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($Block['interrupted']))
|
||||
{
|
||||
$Block['li']['text'] []= '';
|
||||
@ -611,6 +610,8 @@ class Parsedown
|
||||
|
||||
unset($Block['li']);
|
||||
|
||||
$text = isset($matches[2]) ? $matches[2] : '';
|
||||
|
||||
$Block['li'] = array(
|
||||
'name' => 'li',
|
||||
'handler' => 'li',
|
||||
@ -623,6 +624,7 @@ class Parsedown
|
||||
|
||||
return $Block;
|
||||
}
|
||||
}
|
||||
|
||||
if ($Line['text'][0] === '[' and $this->blockReference($Line))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user