voku / HtmlMin

:clamp: HtmlMin: HTML Compressor and Minifier via PHP
MIT License
161 stars 22 forks source link

Invalid whitespace trimming around <em> within <p> #9

Closed Bilge closed 6 years ago

Bilge commented 6 years ago

Given the following code:

<p>Foo <em>bar</em> baz.</p>

By default the minifier outputs:

<p>Foo<em>bar</em>baz.</p>

This means "foo bar baz" now reads "foobarbaz" on screen. This is not equivalent and therefore invalid.

Footnote

It may be worth noting this is not even consistent, depending on other markup that may be used within the p element. For example:

<p>Foo <br> bar <em>baz</em> bat.</p>

Becomes:

<p>Foo<br> bar <em>baz</em>bat.</p>

This means "foo bar baz bat" now reads "foo bar bazbat" on screen. That is, insertion of the <br> element causes some whitespace to be preserved that otherwise, due to this bug, would not be.