alikothari / htmlcompressor

Automatically exported from code.google.com/p/htmlcompressor
Apache License 2.0
0 stars 0 forks source link

Space removal after p and br tags #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the compressor keeps the spaces after p and br tags, while they could be safely 
removed (at least as an option)

Original issue reported on code.google.com by saez.pad...@gmail.com on 11 Sep 2011 at 10:34

GoogleCodeExporter commented 9 years ago
Do you mean even when the removing spaces between tags option is off? 

I think spaces around any tag matter the same, <br> and <p> shouldn't have 
special treatment. Not sure if it's worth adding a special setting just for 
this. 

Original comment by serg472@gmail.com on 11 Sep 2011 at 5:03

GoogleCodeExporter commented 9 years ago
when removing spaces between tags option is on:

<br/> 
Hi man<p>  
Your code has spaces</p>

is compressed as:

<br/> Hi man<p> Your code has spaces</p>

when it could be compressed as

<br/>Hi man<p>Your code has spaces</p>

but that's ok as the spaces are not between tags, but p and br are special in 
the sense that they produce a new line and spaces, new lines and tabs after 
those tags are ignored

I think it should be optionall because the 'new line' behaviour of br and p 
could be overriden by css. I also think that this will also happen with all 
other tags that have a new line behaviour like h1, h2 ...

Original comment by saez.pad...@gmail.com on 12 Sep 2011 at 7:21

GoogleCodeExporter commented 9 years ago
Ok, I will wait if someone else would vote for this feature before implementing 
it. 

The only common thing between <p> and <br> is that they have "display:block" by 
default, but so does a whole bunch of other tags (even <div>). I am still not 
convinced that it should treat p and br in a special way, as there is no way of 
telling which "display" is set for them through css. 

There is no black and white, <div>'s with "display:inline" are probably on 80% 
sites, <p>'s - on 5%, and while inline <br> is not something I ever seen, it is 
still possible. So how to decide which tags to include (<br>, <p>, <h..>, <ul>, 
<li>, ???)

Original comment by serg472@gmail.com on 12 Sep 2011 at 4:12

GoogleCodeExporter commented 9 years ago
ul/li are more dangerous as they are commonly used to make horizontal menus, 
while p,br and h as almost 100% displayed as block, there are other better ways 
to do the same thing as using this tags inline (span, div ...)

maybe it could be a configurable option so the user could decide by himself to 
enable this option and optionally which tags to process, i.e

--remove-spaces-after-tags

will remove spaces after pre-configured tags (p,br,...)

--remove-spaces-after-tags=p,br

will remove spaces after user defined tags

Original comment by saez.pad...@gmail.com on 12 Sep 2011 at 4:36

GoogleCodeExporter commented 9 years ago
Implemented in 1.5.2 release.

There is --remove-surrounding-spaces <min|max|all|custom_list> option for 
command line compressor, that would remove spaces around provided tags (with 
corresponding setRemoveSurroundingSpaces() setting for API)

min: 
html,head,body,br,p

max (those with default block display plus table tags, except <div> and <li>): 
min + 
h1,h2,h3,h4,h5,h6,blockquote,center,dl,fieldset,form,frame,frameset,hr,noframes,
ol,table,tbody,tr,td,th,tfoot,thead,ul

all (not recommended): 
any tag

Thanks.

Original comment by serg472@gmail.com on 18 Sep 2011 at 7:15