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

Match CommonMark's rendering a bit better

This commit is contained in:
Aidan Woods 2019-01-27 18:08:57 +00:00
parent 2e0ad27c5e
commit eab734b457
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
2 changed files with 23 additions and 17 deletions

View File

@ -195,25 +195,25 @@ final class Element implements Renderable
if ($this->Contents !== null) {
$html .= '>';
$First = \reset($this->Contents);
if (
$First instanceof Element
&& ! \array_key_exists(\strtolower($First->name()), self::$TEXT_LEVEL_ELEMENTS)
) {
$html .= "\n";
}
if (! empty($this->Contents)) {
foreach ($this->Contents as $C) {
$html .= $C->getHtml();
if (
$C instanceof Element
&& ! \array_key_exists(\strtolower($C->name()), self::$TEXT_LEVEL_ELEMENTS)
) {
$html .= "\n";
}
$html .= $C->getHtml();
}
$Last = \end($this->Contents);
if (
$Last instanceof Element
&& ! \array_key_exists(\strtolower($Last->name()), self::$TEXT_LEVEL_ELEMENTS)
) {
$html .= "\n";
}
}

View File

@ -1,6 +1,8 @@
<ul>
<li>li<ul>
<li>li<ul>
<li>li
<ul>
<li>li
<ul>
<li>li</li>
<li>li</li>
</ul>
@ -12,10 +14,14 @@
</ul>
<hr />
<ul>
<li>level 1<ul>
<li>level 2<ul>
<li>level 3<ul>
<li>level 4<ul>
<li>level 1
<ul>
<li>level 2
<ul>
<li>level 3
<ul>
<li>level 4
<ul>
<li>level 5</li>
</ul>
</li>