mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
Handle subsequent list items which aren't indented sufficiently
Subsequent list items which aren't indented sufficiently are treated as part of the original list, see CommonMark spec example [#256](http://spec.commonmark.org/0.26/#example-256).
This commit is contained in:
parent
a9e1163c85
commit
a3836b1853
@ -562,8 +562,10 @@ class Parsedown
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$requiredIndent = ($Block['indent'] + strlen($Block['data']['marker']));
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$Block['indent'] === $Line['indent']
|
$Line['indent'] < $requiredIndent
|
||||||
and
|
and
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
@ -589,6 +591,8 @@ class Parsedown
|
|||||||
|
|
||||||
$text = isset($matches[1]) ? $matches[1] : '';
|
$text = isset($matches[1]) ? $matches[1] : '';
|
||||||
|
|
||||||
|
$Block['indent'] = $Line['indent'];
|
||||||
|
|
||||||
$Block['li'] = array(
|
$Block['li'] = array(
|
||||||
'name' => 'li',
|
'name' => 'li',
|
||||||
'handler' => 'li',
|
'handler' => 'li',
|
||||||
@ -601,7 +605,7 @@ class Parsedown
|
|||||||
|
|
||||||
return $Block;
|
return $Block;
|
||||||
}
|
}
|
||||||
elseif ($Block['indent'] === $Line['indent'] and $this->blockList($Line))
|
elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -611,8 +615,6 @@ class Parsedown
|
|||||||
return $Block;
|
return $Block;
|
||||||
}
|
}
|
||||||
|
|
||||||
$requiredIndent = ($Block['indent'] + strlen($Block['data']['marker']));
|
|
||||||
|
|
||||||
if ($Line['indent'] >= $requiredIndent)
|
if ($Line['indent'] >= $requiredIndent)
|
||||||
{
|
{
|
||||||
if (isset($Block['interrupted']))
|
if (isset($Block['interrupted']))
|
||||||
@ -631,7 +633,6 @@ class Parsedown
|
|||||||
|
|
||||||
if ( ! isset($Block['interrupted']))
|
if ( ! isset($Block['interrupted']))
|
||||||
{
|
{
|
||||||
// TODO: force multi-line paragraph, this must not parse any new block
|
|
||||||
$text = preg_replace('/^[ ]{0,'.$requiredIndent.'}/', '', $Line['body']);
|
$text = preg_replace('/^[ ]{0,'.$requiredIndent.'}/', '', $Line['body']);
|
||||||
|
|
||||||
$Block['li']['text'] []= $text;
|
$Block['li']['text'] []= $text;
|
||||||
|
Loading…
Reference in New Issue
Block a user