kangax / html-minifier

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

Spaces around inline elements in text are removed #1120

Closed zefir-git closed 2 years ago

zefir-git commented 2 years ago

The following source HTML

<div>
    <p>Foo <a href="#">bar</a> baz.</p>
</div>

Produces

<div><p>Foo<a href="#">bar</a>baz.</p></div>

Except for using conservativeSpaces, is there a way to fix this? I want unneeded spaces removed. Spaces in text are clearly needed.

zefir-git commented 2 years ago

This issue was caused by using @node-minify with @node-minify/html-minifier. I have resolved it by using this package directly without @node-minify.

fseitun-globant commented 2 years ago

Hi @williamd5 ! Could you please expand on your solution? I think I might have been bitten by the same issue. How do you use

this package directly without @node-minify.

?

zefir-git commented 2 years ago

Hi @williamd5 ! Could you please expand on your solution? I think I might have been bitten by the same issue. How do you use

this package directly without @node-minify.

?

I was using a different package (@node-minify) which provides something like a wrapper around this (@html-minifer) and some other minify packages bundled together.

The way to control this behaviour in @html-minifier is with the collapseInlineTagWhitespace option.