django-htmlmin icon indicating copy to clipboard operation
django-htmlmin copied to clipboard

White spaces between <a> tags not being removed

Open matiascelasco opened this issue 10 years ago • 4 comments

I have found that when I write something like this:

<div>
    <a>
        Something
    </a>
    <a>
        Something
    </a>
</div>

The result is:

<div><a>Something</a> <a>Something</a></div>

Instead of:

<div><a>Something</a><a>Something</a></div>

as I expected.

Is there any reason for this? Or it's a bug?

matiascelasco avatar Feb 11 '15 12:02 matiascelasco

I believe that it is a bug.

andrewsmedina avatar Feb 13 '15 21:02 andrewsmedina

Seeing as tags are inline elements, I can't see how this is a bug.

If your initial code was <div><a>Something</a> <a>Something</a></div> you wouldn't expect the space to be removed, so how is the minifier to know that you do want the whitespace removed from your example?

kiwimind avatar Apr 21 '15 07:04 kiwimind

Hmmm... ok. The thing is that, in my production server, nginx is minifying html in a way that removes the spaces. My goal was to use this tool in order to simulate the nginx minification locally and write my styles according to that in order to avoid unexpected results that otherwise would be hidden to me until seeing the page in production.

But you're right, maybe the bug is in the way that nginx minifies html or maybe there is a configuration option I couldn't find

matiascelasco avatar Apr 21 '15 17:04 matiascelasco

this is not a bug! If you render

<div>
    <a>
        Something
    </a>
    <a>
        Something
    </a>
</div>

in a browser it shows Something Something If it changes the content to SomethingSomething it is definitly a bug in the nginx thing.

bastianh avatar Aug 31 '15 14:08 bastianh