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:
parent
2e0ad27c5e
commit
eab734b457
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user