lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

Bug in HTML Minify – Missing spaces after two linebreaks.

Open camya opened this issue 4 years ago • 3 comments

It looks like the HTML Minify parser is a little bit greedy, if there is more than one linebreak. ;) The parser than omits a required space.

You can see it in Example 3 - "Read morehere!" misses the space beween the text "Read more" and the link text "here!". The problem only occurs, if is more than one linebreak.

Output of the markup below:

1.) Read more here! [GOOD] 2.) Read more here! [GOOD] 3.) Read morehere! [BUG - Missing space!]

Test markup:

<p>
	1.) Read more <a href="#">here!</a>
</p>

<p>
	2.) Read more
	<a href="#">here!</a>
</p>

<p>
	3.) Read more

	<a href="#">here!</a>
</p>

Reference: Report in WordPress forum

camya avatar Jun 14 '20 10:06 camya

Does the extra linebreak mean anything to HTML? Won't it be replaced to one "space" when displaying?

hi-hai avatar Jun 15 '20 13:06 hi-hai

For me, it's only a formating decision for a better overview in my code. But that's normally totally fine, because the normal HTML behaviour is, that the spaces & new lines collapse to one space.

I think, there are some exception like text in <pre> and <textarea>. Guess, there are some other exceptions I don't know.

If I deactive the LSCache HTML Minifier, everthink looks like expected. The problem only occurs, if I activate it. (And only, if there is a extra new line like in example 3.)

I first thought, this could be a side effect with another plugin, but it also happens, if I add the HTML programmatically to the site (Not in the Post editor.) and than activate the Minifier.

camya avatar Jun 15 '20 20:06 camya

I tried it again with all other plugins deactivated. The input / output looks like this.

Markup:

image

Output

image

camya avatar Jun 15 '20 22:06 camya