erusev / parsedown-extra

Markdown Extra Extension for Parsedown
MIT License
819 stars 123 forks source link

Prevent trimming of new line characters in DOMDocument #155

Open lukasleitsch opened 4 years ago

lukasleitsch commented 4 years ago

Some PHP environments trims the new line characters of the loaded HTML in a DOMDocument. But the new line characters are needed to split the lines.

Fix #153

PHP-Version: 7.4.9 Parsedown: 1.8.0-beta-7 ParsedownExtra: 0.8.0

Input

<div markdown="1">
## Headline
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>

<ul>
<li>Second Foo</li>
<li>Second Bar</li>
</ul>
</div>

Local machine output

<div>
<h2>Headline</h2>
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>
<ul>
<li>Second Foo</li>
<li>Second Bar</li>
</ul>
</div>

Production server output

<div>
<h2>Headline</h2>
<ul><li>Foo</li>
<li>Bar</li>
</ul>
</div>

The second list is missing on the production server. The cause is DOMDocument trims the new line characters in some PHP environments.

This PR adds the formatOutput property to the DOMDocument Object to solve the issue.