mrclay/minify

HTML minimization: whitespace around `<li>` should not be trimmed

xuhdev opened this issue · 3 comments

The HTML minifier removes whitespace around <li> as a "blocked/undisplayed element":

.'|frame(?:set)?|h[1-6]|head|header|hgroup|hr|html|legend|li|link|main|map|menu|meta|nav'

However, <li> is commonly modified to be inline (e.g., "The Whitespace Issue" section here, tag clouds in WordPress themes Twenty Twelve and Twenty Seventeen). This often breaks the rendering of <li> elements.

voku commented

@xuhdev hi, can you please test the HtmlMin library for html compressing (https://github.com/voku/HtmlMin) or can you give me some example code (input + what you expected), thanks!

I am currently thinking of a pull request, so that we can use "HtmlMin" directly via this library, but first I wanted to know if this has some benefits for the users.

@xuhdev just a comment, but li is a block-level element so it should be minified and all whitespace removed. This seems like not a bug.

One suggestion when you set li to display: inline like in your tag cloud example is to apply whitespace using margin/padding, or using pseudo elements. Here's an example of that:

li.inline {
  display: inline;
  list-style: none;
}
li.inline:after {
  content: ' ';
}
hpvd commented

I am currently thinking of a pull request, so that we can use "HtmlMin" directly via this library, but first I wanted to know if this has some benefits for the users.

+1