1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

(beginning to) improve commonmark compliance:lists

These changes aren't fit for merge, nor do they work correctly (yet)
This commit is contained in:
Aidan Woods 2016-10-11 12:05:33 +01:00 committed by GitHub
parent cbc4b3f612
commit c4d4a6800d

View File

@ -509,6 +509,11 @@ class Parsedown
$Block = array(
'indent' => $Line['indent'],
'pattern' => $pattern,
'data' => array(
'type' => $name,
'matchText' => ($name === 'ul' ? stristr($matches[1], ' ', true) : stristr($matches[1], '.', true)),
'rootItem' => $matches[2]
),
'element' => array(
'name' => $name,
'handler' => 'elements',
@ -541,7 +546,19 @@ class Parsedown
protected function blockListContinue($Line, array $Block)
{
if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
if (
(
$Block['indent'] === $Line['indent']
and $Block['data']['type'] === 'ol'
and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)
)
or
(
$Block['indent'] === $Line['indent']
and $Block['data']['type'] === 'ul'
and preg_match('/^'.preg_quote($Block['data']['matchText']).'(?:[ ]+(.*)|$)/', $Line['text'], $matches)
)
)
{
if (isset($Block['interrupted']))
{
@ -566,6 +583,11 @@ class Parsedown
return $Block;
}
elseif ($Block['indent'] === $Line['indent'])
{
echo $Block['data']['rootItem'] ."\t" . $Block['indent'] ."\t" . $Block['data']['type'] ."\t" . $Line['indent'] . "\t". $Block['data']['matchText'] ."\t" .$Line['text'] . "\n";
return null;
}
if ($Line['text'][0] === '[' and $this->blockReference($Line))
{