Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent trimming of new line characters in DOMDocument #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukasleitsch
Copy link

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.

Some php environments trims the new line characters of the loaded HTML in a DOMDocument. The new line characters are needed to split the lines.
@lukasleitsch lukasleitsch changed the title Set formatOutput of DOMDocument to true Prevent trimming of new line characters in DOMDocument Aug 10, 2020
bastianallgeier pushed a commit to getkirby/kirby that referenced this pull request Sep 1, 2020
Parsedown Extra trims new line characters in some PHP environments.

Parsedown Extra Issue: erusev/parsedown-extra#153
Parsedown Extra PR: erusev/parsedown-extra#155
bastianallgeier pushed a commit to getkirby/kirby that referenced this pull request Sep 15, 2020
Parsedown Extra trims new line characters in some PHP environments.

Parsedown Extra Issue: erusev/parsedown-extra#153
Parsedown Extra PR: erusev/parsedown-extra#155
bastianallgeier pushed a commit to getkirby/kirby that referenced this pull request Sep 15, 2020
Parsedown Extra trims new line characters in some PHP environments.

Parsedown Extra Issue: erusev/parsedown-extra#153
Parsedown Extra PR: erusev/parsedown-extra#155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paragraphs/HTML blocks may disappear in HTML block with markdown="1"
1 participant