Re: Comment syntax

(12/08/27 20:07), Pete Boere wrote:
> Double slashes in unquoted urls would trip-up regex based minification.
> 
> @import url( http://dont.com/even/look.css )
> @import url( sccidental//but-valid/double/slash-path.css )

Good point. You need to isolate unquoted url(), as long as strings,
before removing comments. In fact, if you don't do that, the
minification would already be buggy in a case like

  @import url( /path/*file* )

, where "/*" is mistreated as the start of a comment.

> Drupal (one example) currently uses regex minification for its CSS files.

I filed a bug[1] to Drupal for the "/path/*file*" thing and sent along a
patch. The regex I used for unquoted urls was

  url\(\s*(?:\\\\.|[^ \n\r\f\)\'"\\\\])[^\)\\\\]*(?:\\\\.[^\)\\\\]*)*\)

(This doesn't support "\url( /path/*file* )", but I am not going to bother.)

By the way, the Drupal CSS minimizer turns line feeds to whitespaces,
like YUI compressor, so it's in the list problematic CSS minimizers (if
we are adding //-style comments).



[1] http://drupal.org/node/1761498


Cheers,
Kenny
-- 
Web Specialist, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/

Received on Wednesday, 29 August 2012 06:53:35 UTC