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

Merge pull request #587 from aidantwoods/fix/ol-interrupt

Fix ordered list interrupt
This commit is contained in:
Aidan Woods 2018-03-28 15:43:44 +01:00 committed by GitHub
commit 40b9da7837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View File

@ -523,7 +523,7 @@ class Parsedown
#
# List
protected function blockList($Line)
protected function blockList($Line, array $CurrentBlock = null)
{
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}[.\)]');
@ -556,12 +556,20 @@ class Parsedown
),
);
if($name === 'ol')
if ($name === 'ol')
{
$listStart = ltrim(strstr($matches[1], $Block['data']['markerType'], true), '0') ?: '0';
if($listStart !== '1')
if ($listStart !== '1')
{
if (
isset($CurrentBlock)
and ! isset($CurrentBlock['type'])
and ! isset($CurrentBlock['interrupted'])
) {
return;
}
$Block['element']['attributes'] = array('start' => $listStart);
}
}

View File

@ -10,4 +10,7 @@
<p>large numbers:</p>
<ol start="123">
<li>one</li>
</ol>
</ol>
<p>foo 1. the following should not start a list
100.<br />
200. </p>

View File

@ -8,4 +8,8 @@ repeating numbers:
large numbers:
123. one
123. one
foo 1. the following should not start a list
100.
200.