Skip to content

Commit 0a5b5fa

Browse files
committed
[FIX] list item with single paragraph
List items with a single paragraph should be reduced to a inline node as paragraph have impact on markup. We do the same thing for RST based documentation. (cherry picked from commit 0c9e12f)
1 parent 97dfc49 commit 0a5b5fa

File tree

8 files changed

+49
-125
lines changed

8 files changed

+49
-125
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
use phpDocumentor\Guides\MarkupLanguageParser;
2222
use phpDocumentor\Guides\Nodes\ListItemNode;
2323
use phpDocumentor\Guides\Nodes\Node;
24+
use phpDocumentor\Guides\Nodes\ParagraphNode;
2425
use Psr\Log\LoggerInterface;
2526
use RuntimeException;
2627

28+
use function count;
29+
use function current;
2730
use function sprintf;
2831

2932
/** @extends AbstractBlockParser<ListItemNode> */
@@ -58,6 +61,10 @@ public function parse(MarkupLanguageParser $parser, NodeWalker $walker, CommonMa
5861
$prefix = $commonMarkNode->getListData()->bulletChar ?? $commonMarkNode->getListData()->delimiter ?? '';
5962
$ordered = $commonMarkNode->getListData()->type === ListBlock::TYPE_ORDERED;
6063

64+
if (count($content) === 1 && current($content) instanceof ParagraphNode) {
65+
$content = current($content)->getChildren();
66+
}
67+
6168
return new ListItemNode($prefix, $ordered, $content);
6269
}
6370

tests/Integration/tests-full/md-to-rst/blockquote-md-to-rst/expected/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Blockquotes with Other Elements
1717
The quarterly results look great!
1818

1919
* Revenue was off the chart.
20-
2120
* Profits were higher than ever.
2221

2322
*Everything* is going according to **plan**.

tests/Integration/tests-full/md-to-rst/md-to-rst-list-link/expected/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ TYPO3 Extension powermail - Documentation
55
This documentation helps
66

77
* Administrators to install and configure powermail
8-
98
* Editors to use powermail
10-
119
* Developers to extend powermail
1210

1311
Example Screenshots
@@ -49,5 +47,4 @@ Documentation overview
4947
======================
5048

5149
* `Introduction <https://github.com/in2code-de/powermail/blob/develop/Documentation/Readme.md>`__
52-
5350
* `Documentation for editors <https://github.com/in2code-de/powermail/blob/develop/Documentation/ForEditors/Readme.md>`__

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ <h2>Blockquotes with Other Elements</h2>
1919

2020

2121
<ul>
22-
<li class="dash">
23-
<p>Revenue was off the chart.</p>
24-
</li>
25-
<li class="dash">
26-
<p>Profits were higher than ever.</p>
27-
</li>
22+
<li class="dash">Revenue was off the chart.</li>
23+
<li class="dash">Profits were higher than ever.</li>
2824
</ul>
2925

3026
<p><em>Everything</em> is going according to <strong>plan</strong>.</p>

tests/Integration/tests/markdown/link-page-md/expected/index.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ <h1>Markdown with links</h1>
77

88

99
<ul>
10-
<li>
11-
<p><a href="/page1.html">Page 1</a></p>
12-
</li>
13-
<li>
14-
<p><a href="/page1.html">Page 1</a></p>
15-
</li>
16-
<li>
17-
<p><a href="/subpages/subpage1.html">Subpage 1</a></p>
18-
</li>
10+
<li><a href="/page1.html">Page 1</a></li>
11+
<li><a href="/page1.html">Page 1</a></li>
12+
<li><a href="/subpages/subpage1.html">Subpage 1</a></li>
1913
</ul>
2014

2115
</div>

tests/Integration/tests/markdown/link-page-md/expected/subpages/index.html

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@ <h1>Markdown with links</h1>
77

88

99
<ul>
10-
<li>
11-
<p><a href="/subpages/subpage1.html">Subpage 1</a></p>
12-
</li>
13-
<li>
14-
<p><a href="/page1.html">Page 1</a></p>
15-
</li>
16-
<li>
17-
<p><a href="/page1.html">Page 1</a></p>
18-
</li>
19-
<li>
20-
<p><a href="/page1.html">Page 1</a></p>
21-
</li>
22-
<li>
23-
<p><a href="/page1.html">Page 1</a></p>
24-
</li>
10+
<li><a href="/subpages/subpage1.html">Subpage 1</a></li>
11+
<li><a href="/page1.html">Page 1</a></li>
12+
<li><a href="/page1.html">Page 1</a></li>
13+
<li><a href="/page1.html">Page 1</a></li>
14+
<li><a href="/page1.html">Page 1</a></li>
2515
</ul>
2616

2717
</div>

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
<!-- content start -->
2-
<div class="section" id="markdown-lists">
2+
3+
<div class="section" id="markdown-lists">
34
<h1>Markdown Lists</h1>
45
<div class="section" id="unordered">
56
<h2>Unordered</h2>
67

78

89
<ul>
9-
<li class="dash">
10-
<p>Item 1</p>
11-
</li>
10+
<li class="dash">Item 1</li>
1211
<li class="dash">
1312
<p>Item 2</p>
1413

1514

1615
<ul>
17-
<li class="dash">
18-
<p>Subitem A</p>
19-
</li>
20-
<li class="dash">
21-
<p>Subitem B</p>
22-
</li>
16+
<li class="dash">Subitem A</li>
17+
<li class="dash">Subitem B</li>
2318
</ul>
2419
</li>
25-
<li class="dash">
26-
<p>Item 3</p>
27-
</li>
20+
<li class="dash">Item 3</li>
2821
</ul>
2922

3023
</div>
@@ -33,25 +26,17 @@ <h2>Ordered</h2>
3326

3427

3528
<ol>
36-
<li>
37-
<p>First item</p>
38-
</li>
29+
<li>First item</li>
3930
<li>
4031
<p>Second item</p>
4132

4233

4334
<ol>
44-
<li>
45-
<p>Subitem A</p>
46-
</li>
47-
<li>
48-
<p>Subitem B</p>
49-
</li>
35+
<li>Subitem A</li>
36+
<li>Subitem B</li>
5037
</ol>
5138
</li>
52-
<li>
53-
<p>Third item</p>
54-
</li>
39+
<li>Third item</li>
5540
</ol>
5641

5742
</div>

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

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,11 @@ <h2>Table of Contents</h2>
99

1010

1111
<ul>
12-
<li class="dash">
13-
<p><a href="#installation">Installation</a></p>
14-
</li>
15-
<li class="dash">
16-
<p><a href="#usage">Usage</a></p>
17-
</li>
18-
<li class="dash">
19-
<p><a href="#safety-guidelines">Safety Guidelines</a></p>
20-
</li>
21-
<li class="dash">
22-
<p><a href="#maintenance">Maintenance</a></p>
23-
</li>
24-
<li class="dash">
25-
<p><a href="#troubleshooting">Troubleshooting</a></p>
26-
</li>
12+
<li class="dash"><a href="#installation">Installation</a></li>
13+
<li class="dash"><a href="#usage">Usage</a></li>
14+
<li class="dash"><a href="#safety-guidelines">Safety Guidelines</a></li>
15+
<li class="dash"><a href="#maintenance">Maintenance</a></li>
16+
<li class="dash"><a href="#troubleshooting">Troubleshooting</a></li>
2717
</ul>
2818

2919
<hr />
@@ -36,15 +26,9 @@ <h2>Installation</h2>
3626

3727

3828
<ol>
39-
<li>
40-
<p><strong>Choose a Sturdy Location:</strong> Select a location with a sturdy beam or swing set structure capable of supporting the weight of the swing and the child.</p>
41-
</li>
42-
<li>
43-
<p><strong>Securely Attach the Swing:</strong> Use strong and reliable <a href="https://example.com/ropes">ropes</a> or chains to securely attach the swing to the chosen location. Double-check the knots or hardware to ensure they are tight and safe.</p>
44-
</li>
45-
<li>
46-
<p><strong>Adjust the Height:</strong> Adjust the height of the swing to a level that is comfortable for your child. Ensure that it is not too high or too low.</p>
47-
</li>
29+
<li><strong>Choose a Sturdy Location:</strong> Select a location with a sturdy beam or swing set structure capable of supporting the weight of the swing and the child.</li>
30+
<li><strong>Securely Attach the Swing:</strong> Use strong and reliable <a href="https://example.com/ropes">ropes</a> or chains to securely attach the swing to the chosen location. Double-check the knots or hardware to ensure they are tight and safe.</li>
31+
<li><strong>Adjust the Height:</strong> Adjust the height of the swing to a level that is comfortable for your child. Ensure that it is not too high or too low.</li>
4832
</ol>
4933

5034
</div>
@@ -53,12 +37,8 @@ <h2>Usage</h2>
5337

5438

5539
<ol>
56-
<li>
57-
<p><strong>Place the Child in the Swing:</strong> Gently place your child in the swing seat, ensuring they are properly seated and secure.</p>
58-
</li>
59-
<li>
60-
<p><strong>Hold onto the Swing:</strong> Provide support and hold onto the swing until your child is comfortably seated and ready to swing.</p>
61-
</li>
40+
<li><strong>Place the Child in the Swing:</strong> Gently place your child in the swing seat, ensuring they are properly seated and secure.</li>
41+
<li><strong>Hold onto the Swing:</strong> Provide support and hold onto the swing until your child is comfortably seated and ready to swing.</li>
6242
<li>
6343
<p><strong>Start Swinging:</strong> Give a gentle push to start the swinging motion. Observe your child&#039;s comfort level and adjust the swinging speed accordingly.</p>
6444
<pre><code class="language-">procedure startSwinging(swing, child)
@@ -70,9 +50,7 @@ <h2>Usage</h2>
7050

7151
</code></pre>
7252
</li>
73-
<li>
74-
<p><strong>Supervise Always:</strong> Always supervise your child while they are using the swing. Ensure they are using it safely and within the recommended age and weight limits.</p>
75-
</li>
53+
<li><strong>Supervise Always:</strong> Always supervise your child while they are using the swing. Ensure they are using it safely and within the recommended age and weight limits.</li>
7654
</ol>
7755

7856
<blockquote>
@@ -83,12 +61,8 @@ <h3>Additional Tips:</h3>
8361

8462

8563
<ul>
86-
<li class="dash">
87-
<p>Bring your child&#039;s favorite toys to make swinging even more enjoyable.</p>
88-
</li>
89-
<li class="dash">
90-
<p>Consider creating a soft landing area with cushions or grass underneath the swing.</p>
91-
</li>
64+
<li class="dash">Bring your child&#039;s favorite toys to make swinging even more enjoyable.</li>
65+
<li class="dash">Consider creating a soft landing area with cushions or grass underneath the swing.</li>
9266
</ul>
9367

9468
</div>
@@ -98,18 +72,10 @@ <h2>Safety Guidelines</h2>
9872

9973

10074
<ol>
101-
<li>
102-
<p><strong>Check Hardware Regularly:</strong> Periodically inspect the ropes or chains, as well as any hardware used to attach the swing. Replace any damaged or worn-out parts immediately.</p>
103-
</li>
104-
<li>
105-
<p><strong>Set Age and Weight Limits:</strong> Follow the manufacturer&#039;s recommended age and weight limits for the swing. Do not exceed these limits to ensure safety.</p>
106-
</li>
107-
<li>
108-
<p><strong>Use Proper Attire:</strong> Encourage your child to wear appropriate clothing, including closed-toe shoes, to prevent any injuries.</p>
109-
</li>
110-
<li>
111-
<p><strong>No Rough Play:</strong> Instruct your child not to engage in rough play or attempt to stand up in the swing.</p>
112-
</li>
75+
<li><strong>Check Hardware Regularly:</strong> Periodically inspect the ropes or chains, as well as any hardware used to attach the swing. Replace any damaged or worn-out parts immediately.</li>
76+
<li><strong>Set Age and Weight Limits:</strong> Follow the manufacturer&#039;s recommended age and weight limits for the swing. Do not exceed these limits to ensure safety.</li>
77+
<li><strong>Use Proper Attire:</strong> Encourage your child to wear appropriate clothing, including closed-toe shoes, to prevent any injuries.</li>
78+
<li><strong>No Rough Play:</strong> Instruct your child not to engage in rough play or attempt to stand up in the swing.</li>
11379
</ol>
11480

11581
</div>
@@ -118,15 +84,9 @@ <h2>Maintenance</h2>
11884

11985

12086
<ol>
121-
<li>
122-
<p><strong>Clean the Swing:</strong> Wipe down the swing seat regularly to keep it clean and free from dirt or debris.</p>
123-
</li>
124-
<li>
125-
<p><strong>Inspect for Wear:</strong> Check the swing&#039;s components for signs of wear or damage. Replace any worn-out parts promptly.</p>
126-
</li>
127-
<li>
128-
<p><strong>Tighten Loose Hardware:</strong> Ensure that all nuts and bolts are securely tightened to maintain stability.</p>
129-
</li>
87+
<li><strong>Clean the Swing:</strong> Wipe down the swing seat regularly to keep it clean and free from dirt or debris.</li>
88+
<li><strong>Inspect for Wear:</strong> Check the swing&#039;s components for signs of wear or damage. Replace any worn-out parts promptly.</li>
89+
<li><strong>Tighten Loose Hardware:</strong> Ensure that all nuts and bolts are securely tightened to maintain stability.</li>
13090
</ol>
13191

13292
</div>
@@ -135,17 +95,13 @@ <h2>Troubleshooting</h2>
13595

13696

13797
<ul>
138-
<li class="dash">
139-
<p><strong>Swing Doesn&#039;t Move Smoothly:</strong> Check for any knots or tangles in the ropes or chains. Untangle and ensure a smooth swinging motion.</p>
140-
</li>
98+
<li class="dash"><strong>Swing Doesn&#039;t Move Smoothly:</strong> Check for any knots or tangles in the ropes or chains. Untangle and ensure a smooth swinging motion.</li>
14199
<li class="dash">
142100
<p><strong>Unusual Sounds:</strong> If you hear any creaking or unusual sounds, inspect the hardware for any loose or damaged parts.</p>
143101

144102
<p>If you hear screaming or crying, untangle the child.</p>
145103
</li>
146-
<li class="dash">
147-
<p><strong>Uneven Swinging:</strong> Adjust the height of the swing to achieve a balanced and even swinging motion.</p>
148-
</li>
104+
<li class="dash"><strong>Uneven Swinging:</strong> Adjust the height of the swing to achieve a balanced and even swinging motion.</li>
149105
</ul>
150106

151107

0 commit comments

Comments
 (0)