Skip to content

Commit e840d7b

Browse files
authored
Merge pull request #1249 from phpDocumentor/bugfix/numbered-lists
[BUGFIX] Numbered lists should continue numbering
2 parents 67ee47a + e28307a commit e840d7b

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

packages/guides-markdown/src/Markdown/Parsers/ListBlockParser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ public function parse(MarkupLanguageParser $parser, NodeWalker $walker, CommonMa
4949
}
5050

5151
if ($commonMarkNode instanceof ListBlock) {
52-
return new ListNode($content, $content[0]->isOrdered());
52+
$start = $commonMarkNode->getListData()->start;
53+
54+
return new ListNode(
55+
$content,
56+
$content[0]->isOrdered(),
57+
$start !== null && $start !== 1 ? (string) $start : null,
58+
);
5359
}
5460

5561
$this->logger->warning(sprintf('"%s" node is not yet supported in context %s. ', $commonMarkNode::class, 'List'));

tests/Integration/tests/lists/numbered-lists-defined/expected/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ <h1>Document Title</h1>
2626
<li>This is the second item.</li>
2727
</ol>
2828
</li>
29+
<li value="1">First</li>
30+
<li value="2">Second</li>
31+
</ol>
32+
33+
34+
<p>Intermediary text or image.</p>
35+
36+
37+
38+
<ol start="3" type="1">
39+
<li value="3">Third</li>
2940
</ol>
3041

3142
</div>

tests/Integration/tests/lists/numbered-lists-defined/input/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ Lorem Ipsum Dolor
1414

1515
1. This is an indented numbered list.
1616
#. This is the second item.
17+
18+
1. First
19+
2. Second
20+
21+
Intermediary text or image.
22+
23+
3. Third

tests/Integration/tests/markdown/lists-md/expected/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ <h2>Ordered</h2>
3939
<li>Third item</li>
4040
</ol>
4141

42+
</div>
43+
<div class="section" id="ordered-continued">
44+
<h2>Ordered, continued</h2>
45+
46+
47+
<ol>
48+
<li>First</li>
49+
<li>Second</li>
50+
</ol>
51+
52+
53+
<p>Intermediary text or image.</p>
54+
55+
56+
57+
<ol start="3">
58+
<li>Third</li>
59+
</ol>
60+
4261
</div>
4362
</div>
4463
<!-- content end -->

tests/Integration/tests/markdown/lists-md/input/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@
1414
1. Subitem A
1515
2. Subitem B
1616
3. Third item
17+
18+
## Ordered, continued
19+
20+
1. First
21+
2. Second
22+
23+
Intermediary text or image.
24+
25+
3. Third

0 commit comments

Comments
 (0)