W3C home > Mailing lists > Public > www-style@w3.org > August 2012

Re: Comment syntax

From: Kang-Hao (Kenny) Lu <kanghaol@oupeng.com>
Date: Wed, 29 Aug 2012 14:53:06 +0800
Message-ID: <503DBC52.8020105@oupeng.com>
To: Pete Boere <pete@the-echoplex.net>
CC: WWW Style <www-style@w3.org>
(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

Web Specialist, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/
Received on Wednesday, 29 August 2012 06:53:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:20 UTC