Skip to content

Commit

Permalink
[FIX] list item with single paragraph
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jaapio committed Nov 7, 2024
1 parent 7046d67 commit 0c9e12f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
use phpDocumentor\Guides\MarkupLanguageParser;
use phpDocumentor\Guides\Nodes\ListItemNode;
use phpDocumentor\Guides\Nodes\Node;
use phpDocumentor\Guides\Nodes\ParagraphNode;
use Psr\Log\LoggerInterface;
use RuntimeException;

use function count;
use function current;
use function sprintf;

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

if (count($content) === 1 && current($content) instanceof ParagraphNode) {
$content = current($content)->getChildren();
}

return new ListItemNode($prefix, $ordered, $content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Blockquotes with Other Elements
The quarterly results look great!

* Revenue was off the chart.

* Profits were higher than ever.

*Everything* is going according to **plan**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ TYPO3 Extension powermail - Documentation
This documentation helps

* Administrators to install and configure powermail

* Editors to use powermail

* Developers to extend powermail

Example Screenshots
Expand Down Expand Up @@ -49,5 +47,4 @@ Documentation overview
======================

* `Introduction <https://github.com/in2code-de/powermail/blob/develop/Documentation/Readme.md>`__

* `Documentation for editors <https://github.com/in2code-de/powermail/blob/develop/Documentation/ForEditors/Readme.md>`__
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ <h2>Blockquotes with Other Elements</h2>


<ul>
<li class="dash">
<p>Revenue was off the chart.</p>
</li>
<li class="dash">
<p>Profits were higher than ever.</p>
</li>
<li class="dash">Revenue was off the chart.</li>
<li class="dash">Profits were higher than ever.</li>
</ul>

<p><em>Everything</em> is going according to <strong>plan</strong>.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ <h1>Markdown with links</h1>


<ul>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li>
<p><a href="/subpages/subpage1.html">Subpage 1</a></p>
</li>
<li><a href="/page1.html">Page 1</a></li>
<li><a href="/page1.html">Page 1</a></li>
<li><a href="/subpages/subpage1.html">Subpage 1</a></li>
</ul>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@ <h1>Markdown with links</h1>


<ul>
<li>
<p><a href="/subpages/subpage1.html">Subpage 1</a></p>
</li>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li>
<p><a href="/page1.html">Page 1</a></p>
</li>
<li><a href="/subpages/subpage1.html">Subpage 1</a></li>
<li><a href="/page1.html">Page 1</a></li>
<li><a href="/page1.html">Page 1</a></li>
<li><a href="/page1.html">Page 1</a></li>
<li><a href="/page1.html">Page 1</a></li>
</ul>

</div>
Expand Down
35 changes: 10 additions & 25 deletions tests/Integration/tests/markdown/lists-md/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
<!-- content start -->
<div class="section" id="markdown-lists">

<div class="section" id="markdown-lists">
<h1>Markdown Lists</h1>
<div class="section" id="unordered">
<h2>Unordered</h2>


<ul>
<li class="dash">
<p>Item 1</p>
</li>
<li class="dash">Item 1</li>
<li class="dash">
<p>Item 2</p>


<ul>
<li class="dash">
<p>Subitem A</p>
</li>
<li class="dash">
<p>Subitem B</p>
</li>
<li class="dash">Subitem A</li>
<li class="dash">Subitem B</li>
</ul>
</li>
<li class="dash">
<p>Item 3</p>
</li>
<li class="dash">Item 3</li>
</ul>

</div>
Expand All @@ -33,25 +26,17 @@ <h2>Ordered</h2>


<ol>
<li>
<p>First item</p>
</li>
<li>First item</li>
<li>
<p>Second item</p>


<ol>
<li>
<p>Subitem A</p>
</li>
<li>
<p>Subitem B</p>
</li>
<li>Subitem A</li>
<li>Subitem B</li>
</ol>
</li>
<li>
<p>Third item</p>
</li>
<li>Third item</li>
</ol>

</div>
Expand Down
88 changes: 22 additions & 66 deletions tests/Integration/tests/markdown/readme-md/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@ <h2>Table of Contents</h2>


<ul>
<li class="dash">
<p><a href="#installation">Installation</a></p>
</li>
<li class="dash">
<p><a href="#usage">Usage</a></p>
</li>
<li class="dash">
<p><a href="#safety-guidelines">Safety Guidelines</a></p>
</li>
<li class="dash">
<p><a href="#maintenance">Maintenance</a></p>
</li>
<li class="dash">
<p><a href="#troubleshooting">Troubleshooting</a></p>
</li>
<li class="dash"><a href="#installation">Installation</a></li>
<li class="dash"><a href="#usage">Usage</a></li>
<li class="dash"><a href="#safety-guidelines">Safety Guidelines</a></li>
<li class="dash"><a href="#maintenance">Maintenance</a></li>
<li class="dash"><a href="#troubleshooting">Troubleshooting</a></li>
</ul>

<hr />
Expand All @@ -36,15 +26,9 @@ <h2>Installation</h2>


<ol>
<li>
<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>
</li>
<li>
<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>
</li>
<li>
<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>
</li>
<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>
<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>
<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>
</ol>

</div>
Expand All @@ -53,12 +37,8 @@ <h2>Usage</h2>


<ol>
<li>
<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>
</li>
<li>
<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>
</li>
<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>
<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>
<li>
<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>
<pre><code class="language-">procedure startSwinging(swing, child)
Expand All @@ -70,9 +50,7 @@ <h2>Usage</h2>

</code></pre>
</li>
<li>
<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>
</li>
<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>
</ol>

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


<ul>
<li class="dash">
<p>Bring your child&#039;s favorite toys to make swinging even more enjoyable.</p>
</li>
<li class="dash">
<p>Consider creating a soft landing area with cushions or grass underneath the swing.</p>
</li>
<li class="dash">Bring your child&#039;s favorite toys to make swinging even more enjoyable.</li>
<li class="dash">Consider creating a soft landing area with cushions or grass underneath the swing.</li>
</ul>

</div>
Expand All @@ -98,18 +72,10 @@ <h2>Safety Guidelines</h2>


<ol>
<li>
<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>
</li>
<li>
<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>
</li>
<li>
<p><strong>Use Proper Attire:</strong> Encourage your child to wear appropriate clothing, including closed-toe shoes, to prevent any injuries.</p>
</li>
<li>
<p><strong>No Rough Play:</strong> Instruct your child not to engage in rough play or attempt to stand up in the swing.</p>
</li>
<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>
<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>
<li><strong>Use Proper Attire:</strong> Encourage your child to wear appropriate clothing, including closed-toe shoes, to prevent any injuries.</li>
<li><strong>No Rough Play:</strong> Instruct your child not to engage in rough play or attempt to stand up in the swing.</li>
</ol>

</div>
Expand All @@ -118,15 +84,9 @@ <h2>Maintenance</h2>


<ol>
<li>
<p><strong>Clean the Swing:</strong> Wipe down the swing seat regularly to keep it clean and free from dirt or debris.</p>
</li>
<li>
<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>
</li>
<li>
<p><strong>Tighten Loose Hardware:</strong> Ensure that all nuts and bolts are securely tightened to maintain stability.</p>
</li>
<li><strong>Clean the Swing:</strong> Wipe down the swing seat regularly to keep it clean and free from dirt or debris.</li>
<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>
<li><strong>Tighten Loose Hardware:</strong> Ensure that all nuts and bolts are securely tightened to maintain stability.</li>
</ol>

</div>
Expand All @@ -135,17 +95,13 @@ <h2>Troubleshooting</h2>


<ul>
<li class="dash">
<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>
</li>
<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>
<li class="dash">
<p><strong>Unusual Sounds:</strong> If you hear any creaking or unusual sounds, inspect the hardware for any loose or damaged parts.</p>

<p>If you hear screaming or crying, untangle the child.</p>
</li>
<li class="dash">
<p><strong>Uneven Swinging:</strong> Adjust the height of the swing to achieve a balanced and even swinging motion.</p>
</li>
<li class="dash"><strong>Uneven Swinging:</strong> Adjust the height of the swing to achieve a balanced and even swinging motion.</li>
</ul>


Expand Down

0 comments on commit 0c9e12f

Please sign in to comment.