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

HTML space entities are changed into regular spaces

Open NicolasP opened this issue 10 years ago • 3 comments

BeautifulSoup's formatter='html' should probably be used, although it would be nice not to have all unicode characters converted to entities. Additionally, space between a button and a another tag like a link is lost.

Example source file:

<!DOCTYPE html>
<html>
<body>
    <p>A paragraph with a&nbsp;non-breakable space</p>
    <p>And&ensp;one&thinsp;with various&emsp;spaces</p>
    <a href="#">A link</a>
    <button>A button</button>
</body>
</html>

Minified output:

<!DOCTYPE html><html><head></head><body><p>A paragraph with a non-breakable space</p><p>And one with various spaces</p><a href="#">A link</a><button>A button</button></body></html>

Pictures (input on the left, output on the right):

capture d ecran 2014-03-01 02 35 09 capture d ecran 2014-03-01 02 35 24

NicolasP avatar Mar 01 '14 01:03 NicolasP

Agreed,  's should not be removed.

podiobooks avatar Sep 22 '14 16:09 podiobooks

I also would prefer that &nbsp;'s not be removed. Can't use this actually until that happens (well, not without adding a padding style everywhere I want to just put a space).

dblado avatar Nov 04 '14 05:11 dblado

They seem fine to me. I explicitly give &nbsp; entities in my .po language files, and then with or without the middleware they're coming through for me as hard space characters, which have the same effect as the entity which represents them.

tremby avatar Jul 07 '16 07:07 tremby