Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

Whitespace issue #9

Closed marklagendijk closed 10 years ago

marklagendijk commented 10 years ago

How does minimize currently determine which whitespace it should preserve? The issue I am having is that minimize is stripping whitespace which is used for styling. Take the buttons from Bootstrap, for example. The styling of the buttons relies on the whitespace you have between them. As soon as you remove that whitespace, the buttons are 'glued' together.

I believe the only safe way of reducing whitespace inside elements is replacing each whitespace with a single space. You can't assume, for example, that a div will always be styled as a block.

What is your take on this? Maybe there should be some option(s) added, so the user can decide what should be preserved?

Swaagie commented 10 years ago

The basic premise is to remove as much whitespace as possible by relying on the flowing of elements. Basically inline elements will be surrounded with whitespace if required. For that, both the previous and next element are checked, see the recent addition https://github.com/Moveo/minimize/commit/75ba00e0c1c43237b1340b3952290ee6dc95d02e.

I think the problem with buttons in this case would be the fact that it is actually missing as inline element. From what I found, buttons are treated as inline-block by default, so it actually could be added to the inline list.

As for replacing multiple whitespaces with at least one, I think adding an option for that, e.g. being less restrictive would be a good addition. Definitely open for contributions with regard to configurability.

Swaagie commented 10 years ago

Closing this as not an issue, feel free to re-open when there is need for more discussion