macray / htmlcompressor

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

Doesn't handle NOT IE conditional comments #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example, if you minify the html from www.html5boilerplate.com:

<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <body class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <body class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <body class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]-->

becomes

<!--[if lt IE 7 ]><body class="ie6"><![endif]--><!--[if IE 7 ]><body 
class="ie7"><![endif]--><!--[if IE 8 ]><body class="ie8"><![endif]--><!--[if IE 
9 ]><body class="ie9"><![endif]--><!--[if (gt IE 9)|!(IE)]>

Original issue reported on code.google.com by alistair...@gmail.com on 30 Aug 2010 at 10:00

GoogleCodeExporter commented 9 years ago
The only way to fix this it to preserve everything inside conditional comments 
without changes. If there is no objections then I will go with this method.

Original comment by serg472@gmail.com on 30 Aug 2010 at 6:03

GoogleCodeExporter commented 9 years ago
Could you treat everything inside them as a their own block which needs be 
compressed and just leave these blocks wrapped in the conditional comments?

Original comment by alistair...@gmail.com on 30 Aug 2010 at 10:04

GoogleCodeExporter commented 9 years ago
Fixed in 0.9.3 (using full compression inside).

Thanks.

Original comment by serg472@gmail.com on 3 Sep 2010 at 5:08

GoogleCodeExporter commented 9 years ago
Awesome, working!

Minor nitpicking (run with remove-intertag-spaces):

Input portion:

</head>
<!--[if lt IE 7 ]> <body class="ie6 ie67"> <![endif]-->
<!--[if IE 7 ]> <body class="ie7 ie67"> <![endif]-->
<!--[!(IE)]><!--> <body> <!--<![endif]-->
<div>

Ideal output:

</head><!--[if lt IE 7 ]><body class="ie6 ie67"><![endif]--><!--[if IE 7 
]><body class="ie7 
ie67"><![endif]--><!--[!(IE)]><!--><body><!--<![endif]--><div>

Actual output:

</head> <!--[if lt IE 7 ]><body class="ie6 ie67"><![endif]--> <!--[if IE 7 
]><body class="ie7 ie67"><![endif]--> <!--[!(IE)]><!--><body><!--<![endif]--> 
<div>

There are 4 spaces that would ideally be removed.

Original comment by alistair...@gmail.com on 3 Sep 2010 at 7:29

GoogleCodeExporter commented 9 years ago
will add to todo list, thanks.

Original comment by serg472@gmail.com on 3 Sep 2010 at 3:18

GoogleCodeExporter commented 9 years ago
Excellent! 
Just hit this bug and was happy to see it's already addressed. :D

We will be integrating the htmlcompressor into the html5boilerplate project for 
the 1.0 release.
It's currently in development but its very exciting for us:
http://github.com/paulirish/html5-boilerplate/commits/build

Thanks Alastair and Sergiy!

Original comment by paulir...@google.com on 9 Sep 2010 at 2:17

GoogleCodeExporter commented 9 years ago
Extra spaces around conditional comments are removed in 0.9.4

Original comment by serg472@gmail.com on 13 Nov 2010 at 7:21