mettke / minify-rs

Crate for text minification. Currently supported: html, json
MIT License
1 stars 0 forks source link

Whitespace is also collapsed within code and pre tags #2

Closed Lonami closed 2 years ago

Lonami commented 3 years ago

I really enjoy the dependency-less aspect of this library, but unfortunately it seems to come with a cost. It removes whitespace from tags which care about it, such as <pre> and <code>.

mettke commented 3 years ago

Hey @Lonami,

thanks for the Info. Would you mind giving me a detailed (minimal) example to reproduce the problem. Afterwards I will create a test and push an updated version.

Lonami commented 3 years ago

Darn that was a fast response! Here's an example:

<pre>
    should respect this          does it?
</pre>

The output of this should be exactly the same, however, it currently turns it into:

<pre> should respect this does it? </pre>
mettke commented 3 years ago

Ah yes - I see. It will take me a while - but there will be an update soon. Thanks for reporting!

Lonami commented 3 years ago

The tricky part is recognizing both the opening and closing tag, because there may be arbitrary whitespace between the < and the tag name, and the tag name should be case insensitive. And I don't know if there's more edge cases we should worry about.

mettke commented 2 years ago

Should be fixed with the newest version. However, I'm not dealing with all the edge cases. What should work is whitespaces between the opening tag < but its not case insensitive.