kangax / html-minifier

Javascript-based HTML compressor/minifier (with Node.js support)
http://kangax.github.io/html-minifier/
MIT License
4.95k stars 571 forks source link

collapseInlineTagWhitespace is deleting spaces between content and link text #706

Closed JoeUX closed 8 years ago

JoeUX commented 8 years ago

Here's some source from Wikipedia's article on SpaceWire:

<p><b>SpaceWire</b> is a <a href="/wiki/Spacecraft" title="Spacecraft">spacecraft</a> <a href="/wiki/Communication_network" class="mw-redirect" title="Communication network">communication network</a> based in part on the <a href="/wiki/IEEE_1355" title="IEEE 1355">IEEE 1355</a> standard of communications. It is coordinated by the <a href="/wiki/European_Space_Agency" title="European Space Agency">European Space Agency</a> (ESA) in collaboration with international space agencies including <a href="/wiki/NASA" title="NASA">NASA</a>...

Toggle collapseInlineTagWhitespace (on the web interface) and you get:

<p><b>SpaceWire</b>is a<a href="/wiki/Spacecraft" title="Spacecraft">spacecraft</a><a href="/wiki/Communication_network" title="Communication network" class="mw-redirect">communication network</a>based in part on the<a href="/wiki/IEEE_1355" title="IEEE 1355">IEEE 1355</a>standard of communications. It is coordinated by the<a href="/wiki/European_Space_Agency" title="European Space Agency">European Space Agency</a>(ESA) in collaboration with international space agencies including<a href="/wiki/NASA" title="NASA">NASA</a>

When the collapsed version renders, you get:

SpaceWireis aspacecraftcommunication networkbased in part on theIEEE 1355standard of communications...

That's all I've got so far. Other settings don't seem to interact with this bug. I'm not sure what the ReadMe means when it says "Don't leave any spaces between display:inline; elements when collapsing", but these aren't spaces between two elements unless we think it's the <p> and the <a>, but the latter is nested in the former, and we'd never want link text to be smushed up against surrounding text like this.

alexlamsl commented 8 years ago

The way this works is collapseWhitespace removes whitespace characters which would not affect the rendered results. Meanwhile collapseInlineTagWhitespace removes all whitespaces around tags regardless, which works for cases like custom CSS.

So in terms of feature this is working as expected IMHO. Of course if you think of any improvements to the documentation, PR is welcome :wink:

alexlamsl commented 8 years ago

Closing as the feature is working as expected.