ProcessWire-AIOM-All-In-One-Minify icon indicating copy to clipboard operation
ProcessWire-AIOM-All-In-One-Minify copied to clipboard

HTML minify removes space character between HTML tags

Open Toutouwai opened this issue 9 years ago • 3 comments

I have a script like this:

echo "<p><strong>Label:<strong> <span>Text</span></p>"

The space between the <strong> and the <span> tags is deliberate and should be preserved as a literal space character in the paragraph. But when the "HTML minify" option is on the space character between these tags is stripped out. The same problem occurs if I have an <a> tag after my <strong> tag.

Toutouwai avatar Mar 01 '15 08:03 Toutouwai

Just saw this:

NOTE: AIOM+ removes all whitespaces between two tags. If you explicitly need a whitespace, change the whitespace into an HTML entity: &nbsp;.

This doesn't seem like an adequate solution to me. A non-breaking space is not the same as a space - I want my lines to be able to break at the space character.

Would be nice if HTML minify was smart enough to work out when a literal space character is intended between tags. Looking at a couple of other HTML minify tools, the preserving of these kinds of spaces happens by default or can be enabled through an option. http://www.willpeavy.com/minifier/ http://kangax.github.io/html-minifier/ https://code.google.com/p/htmlcompressor/ Perhaps single spaces between tags could be preserved while multiple spaces are replaced by a single space?

Toutouwai avatar Mar 01 '15 08:03 Toutouwai

Just had the same problem. I think tags in paragraphs should definitely retain their surrounding spaces because often you are "selecting" specific words within the paragraph and then when the HTML is minified it bunches those words together. Not desirable behaviour at all.

phocks avatar Dec 21 '17 06:12 phocks

@phocks try this version (requires php>=7.0.0): https://github.com/matjazpotocnik/ProcessWire-AIOM-All-In-One-Minify/

matjazpotocnik avatar Jan 03 '18 23:01 matjazpotocnik