Coder Social home page Coder Social logo

closure-stylesheets's Introduction

This project is officially end-of-life. Users are welcome to maintain it in a fork, but there will be no more Google-authored changes published. While Closure Stylesheets was ahead of its time when it was first released in 2011, it has since been outpaced by much more active projects with wider community support. Even within Google, we're working on moving all CSS compilation infrastructure to a combination of Sass and PostCSS plugins, including Autoprefixer, RTLCSS, cssnano, postcss-rename, Stylelint, and a few internal plugins that we hope to one day share with the world. Custom properties and calc() are excellent standard CSS options that are widely supported in modern browsers.


Closure Stylesheets

Closure Stylesheets is an extension to CSS that adds variables, functions, conditionals, and mixins to standard CSS. The tool also supports minification, linting, RTL flipping, and CSS class renaming.

Get Closure Stylesheets!

Closure Stylesheets is available as a Java jar named closure-stylesheets.jar. You can either download a precompiled jar or build it from source.

Using Closure Stylesheets requires Java. To make sure that Java is installed correctly, try running the following command to print the list of command-line options for Closure Stylesheets:

java -jar closure-stylesheets.jar --help

CSS Extensions

Internally at Google, Closure Stylesheets are frequently referred to as "Google Stylesheets" or "GSS", so you will see references to GSS in the source code. Some developers prefer to be explicit about which files use the Closure Stylesheets extensions to CSS by using a .gss file extension.

Variables

Variables can be defined in Closure Stylesheets using @def followed by a variable name and then a value. Variables can also be defined in terms of other variables. Consider the following file, variable-example.gss:

@def BG_COLOR              rgb(235, 239, 249);

@def DIALOG_BORDER_COLOR   rgb(107, 144, 218);
@def DIALOG_BG_COLOR       BG_COLOR;

body {
  background-color: BG_COLOR;
}

.dialog {
  background-color: DIALOG_BG_COLOR;
  border: 1px solid DIALOG_BORDER_COLOR;
}

Running java -jar closure-stylesheets.jar --pretty-print variable-example.gss will print:

body {
  background-color: #ebeff9;
}
.dialog {
  background-color: #ebeff9;
  border: 1px solid #6b90da;
}

Functions

Closure Stylesheets provides support for several arithmetic functions:

  • add()
  • sub()
  • mult()
  • divide()
  • min()
  • max()

Each of these functions can take a variable number arguments. Arguments may be purely numeric or CSS sizes with units (though mult() and divide() only allow the first argument to have a unit). When units such as px are specified as part of an argument, all arguments to the function must have the same unit. That is, you may do add(3px, 5px) or add(3ex, 5ex), but you cannot do add(3px, 5ex). Here is an example of when it might be helpful to use add():

@def LEFT_HAND_NAV_WIDTH    180px;
@def LEFT_HAND_NAV_PADDING  3px;

.left_hand_nav {
  position: absolute;
  width: LEFT_HAND_NAV_WIDTH;
  padding: LEFT_HAND_NAV_PADDING;
}

.content {
  position: absolute;
  margin-left: add(LEFT_HAND_NAV_PADDING,  /* padding left */
                   LEFT_HAND_NAV_WIDTH,
                   LEFT_HAND_NAV_PADDING); /* padding right */

}

Running java -jar closure-stylesheets.jar --pretty-print functions-example.gss will print:

.left_hand_nav {
  position: absolute;
  width: 180px;
  padding: 3px;
}
.content {
  position: absolute;
  margin-left: 186px;
}

Although these functions are not as full-featured as CSS3 calc() because they do not allow you to mix units as calc() does, they can still help produce more maintainable stylesheets.

There are also built-in functions that deal with colors. For now, you need to see the code for details, but here are the functions and the arguments that they take:

  • blendColorsHsb(startColor, endColor) blends using HSB values
  • blendColorsRgb(startColor, endColor) blends using RGB values
  • makeMutedColor(backgroundColor, foregroundColor [, saturationLoss])
  • addHsbToCssColor(baseColor, hueToAdd, saturationToAdd, brightnessToAdd)
  • makeContrastingColor(color, similarityIndex)
  • adjustBrightness(color, brightness)
  • saturateColor(color, saturationToAdd) increase saturation in HSL color space
  • desaturateColor(color, saturationToRemove) decrease saturation in HSL color space
  • greyscale(color) full desaturation of a color in HSL color space
  • lighten(color, lightnessToAdd) increase the lightness in HSL color space
  • darken(color, lightnessToRemove) decrease the lightness in HSL color space
  • spin(color, hueAngle) increase or decrease hue of the color, like rotating in a color wheel

There is also a selectFrom() function that behaves like the ternary operator:

/* Implies MYDEF = FOO ? BAR : BAZ; */
@def MYDEF selectFrom(FOO, BAR, BAZ);

This could be used with @def FOO true; to have the effect of @def MYDEF = BAR.

It is also possible to define your own functions in Java by implementing GssFunctionMapProvider and passing the fully-qualified class name to Closure Stylesheets via the --gss-function-map-provider flag. If you choose to do this, you will likely want to compose DefaultGssFunctionMapProvider so that your GssFunctionMapProvider provides your custom functions in addition to the built-in arithmetic functions.

Mixins

Mixins make it possible to reuse a list of parameterized declarations. A mixin definition (@defmixin) can be seen as a function with arguments that contains a list of declarations. At the place where a mixin is used (@mixin), the values for the arguments are defined and the declarations are inserted. A mixin can be used in any place where declarations are allowed.

The names of the arguments in the @defmixin declaration must be all uppercase.

Global constants defined with @def can be used in combination with mixins. They can be used both within the definition of a mixin, or as an argument when using a mixin.

For example, consider defining a mixin in mixin-simple-example.gss that could be used to create a shorthand for declaring the dimensions of an element:

@defmixin size(WIDTH, HEIGHT) {
  width: WIDTH;
  height: HEIGHT;
}

.logo {
  @mixin size(150px, 55px);
  background-image: url('http://www.google.com/images/logo_sm.gif');
}

Running java -jar closure-stylesheets.jar --pretty-print mixin-simple-example.gss prints:

.logo {
  width: 150px;
  height: 55px;
  background-image: url('http://www.google.com/images/logo_sm.gif');
}

Mixins are even more compelling when you consider using them to abstract away cross-browser behavior for styles such as gradients:

@defmixin gradient(POS, HSL1, HSL2, HSL3, COLOR, FALLBACK_COLOR) {
  background-color: FALLBACK_COLOR; /* fallback color if gradients are not supported */
  background-image: -webkit-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR);               /* Chrome 10+,Safari 5.1+ */
  /* @alternate */ background-image: -moz-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* FF3.6+ */
  /* @alternate */ background-image: -ms-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR);  /* IE10 */
  /* @alternate */ background-image: -o-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR);   /* Opera 11.10+ */
}

.header {
  @mixin gradient(top, 0%, 50%, 70%, #cc0000, #f07575);
}

The above is compiled to:

.header {
  background-color: #f07575;
  background-image: -webkit-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);
  background-image: -moz-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);
  background-image: -ms-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);
  background-image: -o-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);
}

See the section on linting for more details on the @alternate annotation.

Conditionals

Variables can be defined using conditionals with @if, @elseif, and @else. The following is a real-world example adapted from the Closure Library, which defines a cross-browser CSS class to apply the style display: inline-block. The Closure Library example uses browser hacks to define .goog-inline-block, but it can be done explicitly in Closure Stylesheets by using conditionals as shown in conditionals-example.gss:

@if (BROWSER_IE) {
  @if (BROWSER_IE6) {
    @def GOOG_INLINE_BLOCK_DISPLAY  inline;
  } @elseif (BROWSER_IE7) {
    @def GOOG_INLINE_BLOCK_DISPLAY  inline;
  } @else {
    @def GOOG_INLINE_BLOCK_DISPLAY  inline-block;
  }
} @elseif (BROWSER_FF2) {
  @def GOOG_INLINE_BLOCK_DISPLAY    -moz-inline-box;
} @else {
  @def GOOG_INLINE_BLOCK_DISPLAY    inline-block;
}

.goog-inline-block {
  position: relative;
  display: GOOG_INLINE_BLOCK_DISPLAY;
}

Values for the conditionals can be set via a --define flag. By default, all conditional variables are assumed to be false, so running java -jar closure-stylesheets.jar --pretty-print conditionals-example.gss will print:

.goog-inline-block {
  position: relative;
  display: inline-block;
}

whereas java -jar closure-stylesheets.jar --define BROWSER_FF2 --pretty-print conditionals-example.gss will print:

.goog-inline-block {
  position: relative;
  display: -moz-inline-box;
}

It is also possible to specify the --define flag multiple times, so java -jar closure-stylesheets.jar --define BROWSER_IE --define BROWSER_IE6 --pretty-print conditionals-example.gss will print:

.goog-inline-block {
  position: relative;
  display: inline;
}

Admittedly, to get the benefit of serving the CSS specific to a particular user agent, one must generate a separate stylesheet for each user agent and then serve it appropriately.

Additional Features

The Closure Stylesheets tool also offers some features that are not extensions to CSS.

Minification

You can concatenate and minify a list of stylesheets with the following command:

java -jar closure-stylesheets.jar input1.css input2.css input3.css

This will print the minified output to standard out. You can also specify a file to write the output to using the --output-file option:

java -jar closure-stylesheets.jar --output-file output.css input1.css input2.css input3.css

Of course, the > operator also works just as well:

java -jar closure-stylesheets.jar input1.css input2.css input3.css > output.css

If you would like to create a vendor-specific stylesheet, you can use the --vendor flag. Current recognized vendors are: WEBKIT, MOZILLA, OPERA, MICROSOFT, and KONQUEROR. When this flag is present, all vendor-specific properties for other vendors will be removed.

Linting

Closure Stylesheets performs some static checks on your CSS. For example, its most basic function is to ensure that your CSS parses: if there are any parse errors, Closure Stylesheets will print the errors to standard error and return with an exit code of 1.

--allowed-non-standard-function, --allow-unrecognized-functions

It will also error out when there are unrecognized function names or duplicate style declarations. For example, if you ran Closure Stylesheets on linting-example.gss:

.logo {
  width: 150px;
  height: 55px;
  background-image: urel('http://www.google.com/images/logo_sm.gif');
  border-color: #DCDCDC;
  border-color: rgba(0, 0, 0, 0.1);
}

Then you would get the following output:

Unknown function \"urel\" in linting-example.gss at line 4 column 21:
  background-image: urel('http://www.google.com/images/logo_sm.gif');
                    ^

Detected multiple identical, non-alternate declarations in the same ruleset.
If this is intentional please use the /* @alternate */ annotation.
border-color:[rgba(0,0,0,0.1)] in linting-example.gss at line 7 column 1:
}
^

2 error(s)

In this particular case, the function urel() should have been url(), though if you are using a function that is not on the whitelist (see CssFunctionNode for the list of recognized functions, which is admittedly incomplete), then you can specify --allowed-non-standard-function to identify additional functions that should be whitelisted:

java -jar closure-stylesheets.jar --allowed-non-standard-function urel linting-example.gss

The --allowed-non-standard-function flag may be specified multiple times.

It is also possible to disable the check for unknown functions altogether using the --allow-unrecognized-functions flag.

Further, in this example, the multiple declarations of border-color are intentional. They are arranged so that user agents that recognize rgba() will use the second declaration whereas those that do not will fall back on the first declaration. In order to suppress this error, use the /* @alternate */ annotation that the error message suggests as follows:

.logo {
  width: 150px;
  height: 55px;
  background-image: url('http://www.google.com/images/logo_sm.gif');
  border-color: #DCDCDC;
  /* @alternate */ border-color: rgba(0, 0, 0, 0.1);
}

This signals that the re-declaration is intentional, which silences the error. It is also common to use this technique with multiple background declarations that use -webkit-linear-gradient, -moz-linear-gradient, etc. In general, using conditionals to select the appropriate declaration based on user agent is preferred; however, that requires the additional overhead of doing user agent detection and serving the appropriate stylesheet, so using the @alternate annotation is a simpler solution.

--allow-unrecognized-properties, --allowed-unrecognized-property

By default, Closure Stylesheets validates the names of CSS properties used in a stylesheet. We have attempted to capture all legal properties in the hardcoded list of recognized properties that is bundled with Closure Stylesheets. However, you can allow properties that aren't in the list with the --allowed-unrecognized-property flag. Consider the file bleeding-edge.gss:

.amplifier {
  /* A hypothetical CSS property recognized by the latest version of WebKit. */
  -webkit-amp-volume: 11;
}

Then running the following:

java -jar closure-stylesheets.jar bleeding-edge.gss

would yield the following error:

-webkit-amp-volume is an unrecognized property in bleeding-edge.gss at line 3 column 3:
  -webkit-amp-volume: 11;
  ^

1 error(s)

You can whitelist -webkit-amp-volume with the --allowed-unrecognized-property flag as follows:

java -jar closure-stylesheets.jar \\
    --allowed-unrecognized-property -webkit-amp-volume bleeding-edge.gss

Like --allowed-non-standard-function, --allowed-unrecognized-property may be specified multiple times, once for each property to whitelist. We discourage using the blanket --allow-unrecognized-properties because it lets through everything, including simple spelling mistakes.

Note that some recognized properties will emit warnings. These warnings will not be silenced with the --allowed-unrecognized-property flag.

RTL Flipping

Closure Stylesheets has support for generating left-to-right (LTR) as well as right-to-left (RTL) stylesheets. By default, LTR is the assumed directionality for both the input and output, though those settings can be overridden by --input-orientation and --output-orientation, respectively.

For example, consider the following stylesheet, rtl-example.gss, which is designed for an LTR page:

.logo {
  margin-left: 10px;
}

.shortcut_accelerator {
  /* Keyboard shortcuts are untranslated; always left-to-right. */
  /* @noflip */ direction: ltr;
  border-right:\t2px solid #ccc;
  padding: 0 2px 0 4px;
}

Generating the equivalent stylesheet to use on an RTL version of the page can be achieved by running java -jar closure-stylesheets.jar --pretty-print --output-orientation RTL rtl-example.gss, which prints:

.logo {
  margin-right: 10px;
}
.shortcut_accelerator {
  direction: ltr;
  border-left: 2px solid #ccc;
  padding: 0 4px 0 2px;
}

Note how the following properties were changed:

  • margin-left became margin-right
  • border-right became border-left
  • The right and left values of padding were flipped.

However, the direction property was unchanged because of the special @noflip annotation. The annotation may also appear on the line before the property instead of alongside it:

  /* @noflip */
  direction: ltr;

Renaming

Closure Stylesheets makes it possible to rename CSS class names in the generated stylesheet, which helps reduce the size of the CSS that is sent down to your users. Of course, this is not particularly useful unless the class names are renamed consistently in the HTML and JavaScript files that use the CSS. Fortunately, you can use the Closure Compiler to update the class names in your JavaScript and Closure Templates to update the class names in your HTML.

To get the benefits of CSS renaming in Closure, instead of referencing a CSS class name as a string literal, you must use that string literal as an argument to goog.getCssName():

// Do the following instead of goog.dom.getElementByClass('dialog-content'):
var element = goog.dom.getElementByClass(goog.getCssName('dialog-content'));

Similarly, in a Closure Template, you must wrap references to CSS classes with the css command:

{namespace example}

/**
 * @param title
 */
{template .dialog}
<div class=\"{css('dialog-content')}\">
  <div class=\"{css('dialog-title')}\">{$title}</title>
  {call .content data=\"all\" /}
</div>
{/template}

When you generate the JavaScript for the template, be sure to use the --cssHandlingScheme GOOG option with SoyToJsSrcCompiler. This ensures that the generated JavaScript code will also use goog.getCssName(). For example, if the above were named dialog.soy, then the following command would be used to create dialog.soy.js:

java -jar SoyToJsSrcCompiler.jar \\
    --shouldProvideRequireSoyNamespaces \\
    --codeStyle concat \\
    --cssHandlingScheme GOOG \\
    --outputPathFormat '{INPUT_FILE_NAME_NO_EXT}.soy.js' \\
    dialog.soy

The contents of the generated dialog.soy.js file are:

// This file was automatically generated from dialog.soy.
// Please don't edit this file by hand.

goog.provide('example');

goog.require('soy');
goog.require('example');


example.dialog = function(opt_data) {
  return '<div class=\"' + goog.getCssName('dialog-content') + '\"><div class=\"' +
      goog.getCssName('dialog-title') + '\">' + soy.$$escapeHtml(opt_data.title) +
      '</title>' + example.content(opt_data) + '</div>';
};

Note the uses of goog.getCssName() in the generated JavaScript file.

Now that all references to CSS class names are wrapped in goog.getCssName(), it is possible to leverage renaming. By default, goog.getCssName() simply returns the argument that was passed to it, so no renaming is done unless a renaming map has been set.

When running Closure Library code without processing it with the Closure Compiler, it is possible to set a renaming map by defining a global variable named CLOSURE_CSS_NAME_MAPPING in JavaScript code that is loaded before the Closure Library's base.js file. For example, if you defined your CSS in a file named dialog.gss:

.dialog-content {
  padding: 10px;
}

.dialog-title {
  font-weight: bold;
}

Then you would run the following command to generate a stylesheet (dialog.css) with renamed classes, as well as the mapping data as a JavaScript file (renaming_map.js):

java -jar closure-stylesheets.jar \\
    --pretty-print \\
    --output-file dialog.css \\
    --output-renaming-map-format CLOSURE_UNCOMPILED \\
    --rename CLOSURE \\
    --output-renaming-map renaming_map.js \\
    dialog.gss

The generated dialog.css would be as follows:

.a-b {
  padding: 10px;
}
.a-c {
  font-weight: bold;
}

while the generated renaming_map.js would be:

CLOSURE_CSS_NAME_MAPPING = {
  \"dialog\": \"a\",
  \"content\": \"b\",
  \"title\": \"c\"
};

An HTML file that uses the renaming map must be sure to include both the generated stylesheet with renamed class names as well as the renaming map:

<!doctype html>
<html>
<head>
  <link rel=\"stylesheet\" href=\"dialog.css\" type=\"text/css\">
</head>
<body>

  <script src=\"renaming_map.js\"></script>
  <script src=\"path/to/base.js\"></script>
  <script>
    goog.require('example');
  </script>
  <script>
    // Your application logic that uses example.dialog() and other code.
  </script>

</body>
</html>

This ensures that when goog.getCssName('dialog-content') is called, it returns 'a-b'. In this way, the abbreviated name is used in place of the original name throughout the code.

An astute reader will note that so far, we have reduced only the size of the stylesheet, but not the JavaScript. To reduce the size of the JavaScript code, we must use the Closure Compiler in either SIMPLE or ADVANCED mode with the --process_closure_primitives flag enabled (it is enabled by default). When enabled, if it finds a call to goog.setCssNameMapping() in any of its inputs, it will use the argument to goog.setCssNameMapping() as the basis of a renaming map that is applied at compile time. To create the appropriate renaming map with Closure Stylesheets, use CLOSURE_COMPILED as the argument to --output-renaming-map-format:

java -jar closure-stylesheets.jar \\
    --pretty-print \\
    --output-file dialog.css \\
    --output-renaming-map-format CLOSURE_COMPILED \\
    --rename CLOSURE \\
    --output-renaming-map renaming_map.js \\
    dialog.gss

This yields the following content for renaming_map.js:

goog.setCssNameMapping({
  \"dialog\": \"a\",
  \"content\": \"b\",
  \"title\": \"c\"
});

Now renaming_map.js is a suitable input for the Closure Compiler. Recall our original snippet of JavaScript code:

var element = goog.dom.getElementByClass(goog.getCssName('dialog-content'));

If passed to the Closure Compiler in SIMPLE mode along with renaming_map.js, it will be transformed to the following after compilation:

var element = goog.dom.getElementByClass(\"a-b\");

This achieves the goal of reducing both CSS and JS file sizes without changing the behavior of the application.

Admittedly, using CSS renaming is a fairly advanced option that requires a well-organized build system to ensure that the appropriate CSS and JS assets are produced for both development and production. See MoreOnCssRenaming for more details on this topic.

Note: it is also possible to exclude certain class names from being renamed by using the --excluded_classes_from_renaming flag. This may be necessary if some of your HTML is generated by a process that does not take CSS renaming into account. For example, if you are using a Python Django server and are using its template system, then any CSS classes used in those templates will not be renamed (unless you introduce a process to do so). In order to ensure that the JS and CSS that use the HTML reference CSS classes consistently, each CSS class in the Django template should be passed as an argument to Closure Stylesheets with the --excluded_classes_from_renaming flag when generating the CSS.

References to CSS class names that are excluded from renaming should never be wrapped in goog.getCssName(), or else they run the risk of being partially renamed.

closure-stylesheets's People

Contributors

benvanik avatar cgdecker avatar cpovirk avatar eunomie avatar iflan avatar jart avatar jrn avatar kluever avatar lukesandberg avatar mikesamuel avatar mknichel avatar nanaze avatar nex3 avatar nick-someone avatar paulcapron avatar roozbehp avatar seanmfoy avatar slaks avatar wesalvaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

closure-stylesheets's Issues

Only last set of box-shadow values being evaluated

Originally reported on Google Code with ID 30

What steps will reproduce the problem?
1. Set a box-shadow with multiple shadows, using @def or @defmixin parameters.
2. All but the last shadow set will quote the names literally in the compiled output.

What is the expected output? What do you see instead?

All the colour constants should be evaluated, eg:

@def FG_LIGHT rgb(255,255,255);
@def FG_MID rgb(128,128,128);
@def FG_DARK rgb(71,71,71);

@defmixin boxshadow(COL1,COL2,COL3) {
box-shadow: inset 0px 0px 0px 1px COL1, inset 0px 2px 1px 0px COL2, inset 0px 0px 0px
2px COL3;
}

@mixin boxshadow(FG_DARK,FG_LIGHT,FG_MID);
or
box-shadow: inset 0px 0px 0px 1px FG_DARK, inset 0px 2px 1px 0px FG_LIGHT, inset 0px
0px 0px 2px FG_MID;


Both should produce:

box-shadow: inset 0px 0px 0px 1px rgb(71,71,71), inset 0px 2px 1px 0px rgb(255,255,255),
inset 0px 0px 0px 2px rgb(128,128,128);

however, both actually produce, respectively:

box-shadow: inset 0px 0px 0px 1px COL1, inset 0px 2px 1px 0px COL2, inset 0px 0px 0px
2px rgb(128,128,128);

and

box-shadow: inset 0px 0px 0px 1px FG_DARK, inset 0px 2px 1px 0px FG_LIGHT, inset 0px
0px 0px 2px rgb(128,128,128);


What version of the product are you using? On what operating system?

Latest compiler (packaged 12/12/12), Windows 7 x64 with Java 7

Please provide any additional information below.

Reported by zulaxia on 2013-01-18 10:12:00

Parameter source_map_output_level cannot be specified

Parameter source_map_output_level cannot be specified.
I took a look at ClosureCommandLineCompiler.java, the following code caused issue:

@option(name = "source_map_output_level", usage = "The level to generate "
+ "source maps. You could choose between DEFAULT, which will generate "
+ "source map only for selectors, blocks, rules, variables and symbol "
+ "mappings, and ALL, which outputs mappings for all elements.")
private SourceMapDetailLevel sourceMapLevel = SourceMapDetailLevel.DEFAULT;

The Option name does not starts with "--" so we unable to pass it to args4j.

I add double hash before parameter name to fix it: #13

Patch for /src/com/google/common/css/compiler/ast/CssFunctionNode.java

Originally reported on Google Code with ID 38

Added new functions.

Reported by GoLocalTeam on 2013-09-04 12:26:49


- _Attachment: [CssFunctionNode.java.patch](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-38/comment-0/CssFunctionNode.java.patch)_

Closure-stylesheets not usable as a simple css minification tool: Too many failures due to IE specific hacks

Originally reported on Google Code with ID 21

Description
-----------
http://www.dojotoolkit.org already uses the Closure-Compiler as a JS minification tool
and explores moving to Closure-Stylesheets for CSS compression. However, the tool seems
not to be usable for this at the moment: Compressing dijit.css, a CSS file shipped
with Dojo (see file attached) triggers numerous errors, and specifing "--allow-unrecognized-functions
 --allow-unrecognized-properties" does not turn off linting. The parser still fails
due to IE specific hacks like "#zoom" (know as star hack, see http://en.wikipedia.org/wiki/CSS_filter#Star_hack)
or IE specific stuff like "top: expression(eval((document.documentElement||document.body).scrollTop));".

What steps will reproduce the problem?
--------------------------------------
Try to compress the attached CSS file with "java -jar closure-stylesheets.jar --allow-unrecognized-functions
 --allow-unrecognized-properties dijit.css". This fails with several errors. Replacing
"#zoom" with "*zoom" gets rid off the error. But there a still problems with stuff
like "expression(....)". Specifying "--allowed-non-standard-function expression" seems
to have no effect. The parser still fails.

What is the expected output? What do you see instead?
-----------------------------------------------------
For simple CSS compression, there should be an option to turn off linting completely?
When using CSS variables and mixings, the parser should not fails either if the CSS
contains cases as mentioned above. 

What version of the product are you using? On what operating system?
--------------------------------------------------------------------
closure-stylesheets-20111230.jar on Win7Home

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)


Please provide any additional information below
------------------------------------------------
Would be cool if Closure-Stylesheets could work with the attached CSS file. Compressing
dijit.css with the YUI-Compressor works like a charm. It would be great if Closure-Stylesheets
could achieve the same compression ratio like the YUI-Compressor. Then it would be
a great alternative and worth a thought adding it to the Dojo release like Closure-Compiler
and thereby replacing LESS and providing higher CSS compression rates (However this
needs further discussions with the Dojo core team, and I am not a member of the core
team).


Reported by oliver.siemoneit on 2012-06-24 12:27:44


- _Attachment: [dijit.css](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-21/comment-0/dijit.css)_ - _Attachment: [claro.css](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-21/comment-0/claro.css)_

Patch for /src/com/google/common/css/compiler/ast/Property.java

Originally reported on Google Code with ID 39

Added new properties.

Reported by mark.kaczkowski on 2013-09-04 12:28:05


- _Attachment: [Property.java.patch](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-39/comment-0/Property.java.patch)_

Extra color functions

Originally reported on Google Code with ID 9

Hi,

Some color functions are missing in closure stylesheets. If I take less in example,
here are some interesting functions http://lesscss.org/#-color-functions

Based on the last commit (http://code.google.com/p/closure-stylesheets/source/detail?r=6edc1c4364256f20dca2b59eddc18e38f1a41935)
I've implemented some of them :
* lighten(color, amount)
* darken(color, amount)
* saturate(color, amount)
* desaturate(color, amount)
* grayscale(color)

I join a patch which add functions. It's just a "quick and dirty" patch (based on the
code of addHsbToCssColor), but it seems to work.
In the hope you find it interesting.

++
Yves

Reported by Yves.Brissaud on 2011-12-02 12:25:33


- _Attachment: [extra_colors.patch](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-9/comment-0/extra_colors.patch)_

Data-uri support

Originally reported on Google Code with ID 7

Would be great to have an ability to preprocess css files that way that data-uri would
appear in css instead of images. As not all browsers support data-uri (IE 7 and earlier,
IE8 only 32Kb), this can be an optional parameter like "--replace_image_with_data_uri".

Also by default root path for image path in css can be considered path to processed
stylesheet. But that could be changed explicitly by providing --root argument. --root
argument can have local folder path or web url images will be fetched from.

Reported by judo.ras on 2011-11-30 07:18:03

GSS - local variables in mixin

It should be possible to declare and use local variable somehow in mixin.
Right now it's possible declare @def in mixin, BUT it will be global variable.
As workaround I can prefix it with mixin name to prevent names conflict, i.e. @def MIXIN_LOCAL 33; but it's very inconvenient.

Latest build from sources does not allow outline-offset property

Originally reported on Google Code with ID 28

What steps will reproduce the problem?

Compiling following test stylesheet:

*:focus {
 outline-offset: -1px;
 outline: 1px solid black;
}

result was:
*:focus{outline:1px solid black}

outline-offset property simply omitted without error.

However, when properties places exchanged (outline property on top),

i got following error:

outline-offset is an unrecognized property in test.css at line 3 column 2:
        outline-offset: -1px;
 ^

1 error(s), 0 warning(s)

What is the expected output? What do you see instead?

Error from compiler or outline-offset option in compiled css.

What version of the product are you using? On what operating system?

Revision: c9f1228275dc

Reported by vbatichko on 2012-10-02 20:48:22

Compiler does not handle backslashes properly

Originally reported on Google Code with ID 20

Discovered when trying to compress output from Twitter Bootstrap (likely affects lots
of other users too).

Michael Bolin addressed this issue in this thread but I don't see a fix ever being
checked in:

http://stackoverflow.com/questions/8453719/closure-stylesheets-parse-error-with-twitters-bootstrap-css

Input:
.test{ font-size:20px;outline:thin dotted \9; }

Output
GssParserException: Parse error in test at line 1 column 44


Reported by ori.schwartz on 2012-05-30 17:58:08

Please add support for text-justify CSS3 property

Originally reported on Google Code with ID 14

What steps will reproduce the problem?
1. Use text-justify CSS3 property.

What is the expected output? What do you see instead?

The compiler doesn't support the text-justify property:

text-justify is an unrecognized property in main.gss at line 387 column 3:
  text-justify: auto;
  ^

1 error(s)

What version of the product are you using? On what operating system?

closure-stylesheets-20111230.jar

Please provide any additional information below.

Reported by ltrabuco on 2012-03-18 14:14:36

ClosureCommandLineCompiler constructor protected but parameter class private

Originally reported on Google Code with ID 17

In the ClosureCommandLineCompiler class the default constructor is protected, but one
of its parameter OutputInfo is private, which will not allow any other class to call
this constructor.

I'm building a system that will call the compiler directly in java without using the
command line itself, but this situation will block my call.

Reported by terciofilho on 2012-04-12 00:12:13

Typo in FileNotFoundException handler

Originally reported on Google Code with ID 12

What steps will reproduce the problem?
1. set "--output-file" to a non-existent file path
2. error message "The compiler encountered an unhadled error condition."

What is the expected output? What do you see instead?
"The compiler encountered an unhandled error condition."

What version of the product are you using? On what operating system?
Build date 20111215. Windows XP

Please provide any additional information below.
Cheers :)

Reported by rviscomi on 2012-02-04 02:18:55

Keyframes syntax not supported

Originally reported on Google Code with ID 26

CSS syntax for @keyframes, @-ms-keyframes and @-o-keyframes is not supported.

What steps will reproduce the problem?
1. java -jar closure-stylesheets-20111230.jar test.css --allow-unrecognized-properties
--allow-unrecognized-functions
2. An error is given for 0% syntax, which is correct.

What is the expected output? What do you see instead?
Minified css expected, instead - parser error.

What version of the product are you using? On what operating system?
20111230, Windows 7

Reported by [email protected] on 2012-08-07 19:23:40


- _Attachment: [test.css](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-26/comment-0/test.css)_

execute mixin in another mixin

Originally reported on Google Code with ID 18

this is a feature

for example 

@defmixin border-radius(RADIUS) {
    @mixin border-radius-corners(RADIUS, RADIUS, RADIUS, RADIUS)
}

@defmixin border-radius-corners(LT, RT, LB, RB) {
    -webkit-border-radius: LT RT LB RB;
    -moz-border-radius: LT RT LB RB;
    border-radius: LT RT LB RB;
}

Reported by randomailer on 2012-05-04 07:18:31

Generate Source Mapping Error when a property value contains comma

What steps will reproduce the problem?
1.Clone the latest closure-stylesheets and compile
2.specify output-source-map when building gss

java -jar build/closure-stylesheets.jar --allow-unrecognized-properties --output-renaming-map-format CLOSURE_UNCOMPILED --rename CLOSURE --output-renaming-map renaming_map.js --output-source-map test.source.map --output-file test.css test.gss

What is the expected output? What do you see instead?
I got an error:

Compiler internal error: null
java.lang.IllegalStateException
at com.google.common.base.Preconditions.checkState(Preconditions.java:133)
at com.google.common.css.compiler.passes.DefaultGssSourceMapGenerator.endSourceMapping(DefaultGssSourceMapGenerator.java:157)
at com.google.common.css.compiler.passes.CodePrinter.leave(CodePrinter.java:103)
at com.google.common.css.compiler.passes.UniformVisitor.leaveImportBlock(UniformVisitor.java:266)
at com.google.common.css.compiler.ast.DefaultVisitController$RootVisitImportBlockState.doVisit(DefaultVisitController.java:387)
at com.google.common.css.compiler.ast.DefaultVisitController.startVisit(DefaultVisitController.java:2028)
at com.google.common.css.compiler.passes.CompactPrinter.runPass(CompactPrinter.java:473)
at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.parseAndPrint(DefaultCommandLineCompiler.java:127)
at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.compile(DefaultCommandLineCompiler.java:110)
at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.execute(DefaultCommandLineCompiler.java:149)
at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.executeJob(ClosureCommandLineCompiler.java:335)
at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.main(ClosureCommandLineCompiler.java:400)

What version of the product are you using? On what operating system?
Latest clone from github, mac os x and java 1.8

Please provide any additional information below.
I generated a gss file that contains comma in the property value and enable output-source-map both, then closure stylesheets throw an exception above.
i also generated a gss file(test2.gss) that not contains comma in the property value, then compile it using same parameter, it works fine.

test.gss:

.test {
font-family: Helvetica, Tahoma;
}

test2.gss

.test2 {
font-family: Helvetica;
}

Import Mixins

Originally reported on Google Code with ID 4

Ability to import mixins from another gss file.

For example, if the borderRadius mixin was defined in the commonMixins.gss file:

@import commonMixins.gss

.myBox {
    @mixin borderRadius(3px);
}

Reported by Zoramite on 2011-11-15 20:42:41

Browser conditioning with short annotation

Originally reported on Google Code with ID 11

I would like to write browser conditioning with less coding.
This seems nice to me,

.item {
  color: green;
  /* @if (IE6) */ color: red;
}

if (--define IE6), two `color' will be output.

Closure Stylesheets would reach more complex web project than usual, so browser conditioning
would be more needed in order to handle performance issues.

What do you think?

Reported by ThePigLovesYou on 2012-02-02 10:29:58

The minification actually makes the stylesheet bigger.

Originally reported on Google Code with ID 2

What steps will reproduce the problem?

1. Create a input.css file:
---------------
#first, #second, #third {
    width: 100px;
    height: 100px;
    color: #ff0000;
    background-color: #00ff00;
}
#second {
    width: 105px;
}
---------------

2. Run: java -jar closure-stylesheets.jar --output-file output.css input.css

What is the expected output? What do you see instead?

Expected (and YUI Compressor achieves this), 100 bytes:
---------------
#first,#second,#third{width:100px;height:100px;color:#f00;background-color:#0f0}#second{width:105px}
---------------

With Closure I get a 204 byte file instead (original was 138!):
---------------
#first{width:100px;height:100px;color:#f00;background-color:#0f0}#second{height:100px;color:#f00;background-color:#0f0}#third{width:100px;height:100px;color:#f00;background-color:#0f0}#second{width:105px}
---------------

What version of the product are you using? On what operating system?

I'm using the initial release, SHA1 5d8092ec7287f8b05b41ff71f52ff2dc0576f414

Windows 7 64bit SP1

Please provide any additional information below.

This sucks big time.

Reported by xxStrom on 2011-11-15 02:44:40

Loading external renaming css-map

Originally reported on Google Code with ID 33

New command line option '--input-rename-css-map-file'.
Ability to load a renaming css-map from external properties file added.
This is necessary if we need to create more than one compressed css-files that have
the same classes.

Reported by igor.demyanov on 2013-04-10 12:44:01

Wrong removal of last semicolon

Originally reported on Google Code with ID 41

What steps will reproduce the problem?
1. Use the following simple CSS:

*,body,.inner-playable-list-item {
  -webkit-user-select: none;
  /* @alternate */
  -khtml-user-select: none;
  /* @alternate */
  -moz-user-select: none;
  /* @alternate */
  -ms-user-select: none;
  /* @alternate */
  user-select: none;
  -webkit-touch-callout: none;
}

2. Use the jar with following options:
--allowed-unrecognized-property user-select
--output-renaming-map-format CLOSURE_COMPILED
--rename CLOSURE


What is the expected output? What do you see instead?
Valid minified CSS file
Instead the following is produced:

*,body,.a-b-c-d{-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-touch-callout:none}

Notice the missing semicolon after the last property value. (none} instead of none;}).

What version of the product are you using? On what operating system?
The jar does not seem to have -version command.


Please provide any additional information below.
The jar was built from the source because several important properties in css are added
after the last official release.

Reported by regardingScot on 2013-10-31 10:08:49

Allow setting OptimizeStrategy for a JobDescription

Originally reported on Google Code with ID 8

It is not possible to specify the OptimizeStrategy in JobDescriptionBuilder because
there is no setter for it.

Working with current HEAD (1 Dec 2011).

Reported by martin.grigorov on 2011-12-01 14:45:14

Closure Stylesheets needs a linter

A linter for closure stylesheets could detect a lot of simple style issues like unsorted @requires, whitespace conventions, etc.

Probably there would be some obvious problems to point out globally and some Google style guidelines documented at https://github.com/google/styleguide that could be enabled via a flag.

background-color excluded from closure-compile if occurs before background: linear-gradient

Originally reported on Google Code with ID 36

What steps will reproduce the problem?
1. create the following css style 
.cssButton {background-color: #00853f; background: linear-gradient(0deg, #00853f, #7BAE3B
); }

2. Run the google closure compiler (version 20111230.jar) against this style

3.  The background-color style is ignored without warning and excluded from the compiled-output-file

4. If you place the background-color AFTER the background: linear-gradient(...) style...
then the compiler at least puts both styles into the compiled output 

What is the expected output? What do you see instead?
expected output is a possible warning or error indicating that the 
background-color attribute will be ignored or excluded from the output-file


What version of the product are you using? On what operating system?
(version 20111230.jar) running on SunOS 5.10 with jre1.6.0_33

Please provide any additional information below.
it's possible that the compiler is correct in excluding the background-color in favor
of the abbreviated syntax "background:...." style but there should be a warning or
error thrown.

Reported by ericjrickard on 2013-06-21 18:00:36

Variable name is expected to be in uppercase only

Originally reported on Google Code with ID 25

What steps will reproduce the problem?
1. Define a variable e.g: @def width 10
2. Use this variable in style as .style1 { width: width; }
3. width is not replaced with the value 10.

What is the expected output? What do you see instead?
Expected output is width to be assigned value 10 which instead is being set as width.

What version of the product are you using? On what operating system?
closure-stylesheet version: using jar closure-stylesheets-20111230.jar
OS: windows7

Please provide any additional information below.
It is no where documented that variable name must be in upper case. It is documented
only for mixins. In code, the condition isDefinitionReference of CssConstantReferenceNode
class is used both for mixins and variable verification and only throws error for mixins
and not variables. Hence, the pareser silently moves forward without replacing the
lower case variable values and we get the issues at later stages.


Reported by nitu.mca on 2012-08-07 10:44:57

Feature request for joining strings

Originally reported on Google Code with ID 35

Would be nice to be able to do something similar to this

@def IMAGES_DIR       '/Content/Images/';

.icon.field.text {
    background-image: url(IMAGES_DIR + 98-CoffeeCup.png);
}

Reported by ali.taft90 on 2013-05-24 13:52:54

Make identical declarations check optional

Originally reported on Google Code with ID 34

What steps will reproduce the problem?
1. java -jar closure-stylesheets-20130114.jar style.css
2. style.css contains multiple declarations of background property in same rule definition
3. error occurs

What is the expected output? What do you see instead?

Expected output would be correctly compiled css file:
body{background:white;background:red}

Instead of that I see following error output:

Detected multiple identical, non-alternate declarations in the same ruleset. If this
is intentional please use the /* @alternate */ annotation. background:[red] in style.css
at line 4 column 1:
}
^

1 error(s), 0 warning(s)

What version of the product are you using? On what operating system?
closure-stylesheets-20130114.jar
jdk-7u17-linux-x64
Ubuntu 11.10 x64

Please provide any additional information below.

Please provide command line argument which can turn off identical declarations check.
Many popular css components / frameworks uses identical property declarations (css3please.com,
jquery mobile, ...). So anytime I am integrating / upgrading such tool I have to fix
their css files with /* @alternate */ command. Would be better to just turn off this
check and save my time.

Reported by martin.sznapka on 2013-04-11 14:57:33

GSS syntax highlighting - eclipse plugin

Originally reported on Google Code with ID 22

I have searched over hours for this , i just found one solution here : 
https://groups.google.com/group/closure-stylesheets-discuss/tree/browse_frm/thread/0f44c33220fe54d8/09a1f2cd660aa8f1?rnum=1&_done=%2Fgroup%2Fclosure-stylesheets-discuss%2Fbrowse_frm%2Fthread%2Ff44c33220fe54d8%2F09a1f2cd660aa8f1%3Ftvc%3D1%26
I think , if Google can release a plugin for eclipse with highlight effect and suggestion
then developer can grow up with this faster

Reported by hau12a1 on 2012-06-27 04:45:18

Improper Parsing of Unicode

Originally reported on Google Code with ID 31

What steps will reproduce the problem?
When a string contains a unicode character specification, it does not parse properly.
Specifically, it works when it is 6 digits long, but not if it is less.

This works:

.rule:after { content: " \00203a "; }

This breaks:

.rule:after { content: " \203a "; }


This should be allowed according to the CSS2 spec:

http://www.w3.org/TR/CSS2/syndata.html#characters

Reported by [email protected] on 2013-03-15 15:13:13

pretty-print flag wrongly adds spaces between multiple negation pseudo-classes (:not)

Originally reported on Google Code with ID 37

What steps will reproduce the problem?
1. Create a test.css file:

    em:not(.a):not(.b) {
      color: red;
    }

2. Create a pretty-printed file with:
    $ java -jarclosure-stylesheets.jar --pretty-print --output-file ./test.p.css test.css

3. Check its contents:

    $ cat test.p.css 
    em:not(.a) :not(.b)  {
      color: red;
    }

This is wrong, because the space added between both :not pseudo-classes changes the
meaning of this selector. The desired 'em' element will not be selected.

What is the expected output? What do you see instead?

The correct output is produced without the pretty-print flag:

    $ java -jar tools/closure-stylesheets.jar --output-file ./test.c.css test.css
    $ cat test.c.css 
    em:not(.a):not(.b){color:red}


What version of the product are you using? On what operating system?

Revision: 86bb800d79a3
Chrome 27.0.1453.116

Please provide any additional information below.

The following change seems to fix this issue (unsure if this is the right fix though).

$ git diff
diff --git a/src/com/google/common/css/compiler/passes/PrettyPrinter.java b/src/com/google/common/css/compiler/passes/PrettyPrinter.java
index 8a37b7c..9da9ab7 100644
--- a/src/com/google/common/css/compiler/passes/PrettyPrinter.java
+++ b/src/com/google/common/css/compiler/passes/PrettyPrinter.java
@@ -347,7 +347,7 @@ public class PrettyPrinter extends DefaultTreeVisitor
   public void leavePseudoClass(CssPseudoClassNode node) {
     if (node.getFunctionType() == FunctionType.NOT) {
       deleteEndingIfEndingIs(", ");
-      sb.append(") ");
+      sb.append(")");
     }
   }

Reported by alo.and on 2013-07-04 21:51:44

@font-face Support

Originally reported on Google Code with ID 5

The compiler seems to stumble when running across this line: 

@font-face { 
  font-family: 'MetaSerifMedium'; 
  src: url('/font/MetaSerifWeb-Medium.eot?') format('eot'), url('/font/ 
MetaSerifWeb-Medium.woff') format('woff'); 
} 

With this error: 

Compiler parsing error: Parse error in gss/app.gss at line 2 column 
16: 
  font-family: 'MetaSerifMedium'; 
               ^ 

com.google.common.css.compiler.ast.GssParserException: Parse error in 
gss/app.gss at line 2 column 16: 
  font-family: 'MetaSerifMedium'; 
               ^ 

at 
com.google.common.css.compiler.ast.GssParserCC.parse(GssParserCC.java: 
162) 
at com.google.common.css.compiler.ast.GssParser.parse(GssParser.java: 
46) 
at 
com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.parseAndPrint(DefaultCommandLineCompiler.java:

107) 
at 
com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.compile(DefaultCommandLineCompiler.java:

96) 
at 
com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.execute(DefaultCommandLineCompiler.java:

132) 
at 
com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.executeJob(ClosureCommandLineCompiler.java:

274) 
at 
com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.main(ClosureCommandLineCompiler.java:

347) 


Is it possible to use @font-face w/ the compiler? Perhaps using a 
different syntax? If it's not, is there planned support? 

Reported by patrick.hawks on 2011-11-21 17:33:40

Problem using mixins or conditionals inside a rule.

Originally reported on Google Code with ID 24

Source files:

--- menu.gss ---
li.social {
    @mixin debug_italics();
    padding-left: 15px;
}

--- 00-debug.gss ---
@if (DEBUG) {
    @defmixin debug_italics() {
            font-style: italics;
    }
} @else {
    @defmixin debug_italics() {
        /* Nothing. */
    }
}

-- OR --

li.social {
    @if (DEBUG) {
        font-style: italic;
    }
    padding-left: 15px;
}

-------------------------------
Neither work, the first example results in:

Compiler internal error: com.google.common.css.compiler.ast.CssMixinNode cannot be
cast to com.google.common.css.compiler.ast.CssDeclarationNode
java.lang.ClassCastException: com.google.common.css.compiler.ast.CssMixinNode cannot
be cast to com.google.common.css.compiler.ast.CssDeclarationNode
    at com.google.common.css.compiler.passes.DisallowDuplicateDeclarations.enterRuleset(DisallowDuplicateDeclarations.java:64)
    at com.google.common.css.compiler.ast.DefaultVisitController$VisitRulesetState.doVisit(DefaultVisitController.java:762)
    at com.google.common.css.compiler.ast.DefaultVisitController.startVisit(DefaultVisitController.java:1762)
    at com.google.common.css.compiler.passes.DisallowDuplicateDeclarations.runPass(DisallowDuplicateDeclarations.java:75)
    at com.google.common.css.compiler.passes.PassRunner.runPasses(PassRunner.java:142)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.parseAndPrint(DefaultCommandLineCompiler.java:106)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.compile(DefaultCommandLineCompiler.java:94)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.execute(DefaultCommandLineCompiler.java:129)
    at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.executeJob(ClosureCommandLineCompiler.java:286)
    at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.main(ClosureCommandLineCompiler.java:359)


--------------------

The second results in:

Compiler internal error: com.google.common.css.compiler.ast.CssUnknownAtRuleNode cannot
be cast to com.google.common.css.compiler.ast.CssDeclarationNode
java.lang.ClassCastException: com.google.common.css.compiler.ast.CssUnknownAtRuleNode
cannot be cast to com.google.common.css.compiler.ast.CssDeclarationNode
    at com.google.common.css.compiler.passes.DisallowDuplicateDeclarations.enterRuleset(DisallowDuplicateDeclarations.java:64)
    at com.google.common.css.compiler.ast.DefaultVisitController$VisitRulesetState.doVisit(DefaultVisitController.java:762)
    at com.google.common.css.compiler.ast.DefaultVisitController.startVisit(DefaultVisitController.java:1762)
    at com.google.common.css.compiler.passes.DisallowDuplicateDeclarations.runPass(DisallowDuplicateDeclarations.java:75)
    at com.google.common.css.compiler.passes.PassRunner.runPasses(PassRunner.java:142)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.parseAndPrint(DefaultCommandLineCompiler.java:106)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.compile(DefaultCommandLineCompiler.java:94)
    at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.execute(DefaultCommandLineCompiler.java:129)
    at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.executeJob(ClosureCommandLineCompiler.java:286)
    at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.main(ClosureCommandLineCompiler.java:359)


------------------

I've tried this with the tip-of-the-tree version, the latest downloadable version,
and the version before that, all with the same errors. What do?

Reported by SeligArkin on 2012-07-22 22:23:27

divide is locale sensitive

The divide function seems locale sensitive.
On a computer with fr_FR as the locale (Windows 7 pro) the compiled CSS for say:

width: divide(BIG_MARGIN, 2);

Where BIG_MARGIN equals "25px" is "12,5px" (a comma). One would expect "12.5px" (a dot)

css calc is not supported

Originally reported on Google Code with ID 40

What steps will reproduce the problem?

1. d:\Work\test>java -jar bin/closure-stylesheets.jar --rename CLOSURE --output-file
build/outputcompiled.css css/test.css

Contents of test.css:

.test{
   width: calc(100% - 1px);
}

What is the expected output? 

Expect to see minified css in file named outputcompiled.css 

What do you see instead?

Compiler parsing error: Parse error in css/test.css at line 2 column 22:
   width: calc(100% - 1px);
                     ^

com.google.common.css.compiler.ast.GssParserException: Parse error in css/test.css
at line 2 column 22:
   width: calc(100% - 1px);
                     ^

        at com.google.common.css.compiler.ast.GssParserCC.parse(GssParserCC.java:176)
        at com.google.common.css.compiler.ast.GssParser.parse(GssParser.java:46)
        at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.parseAndPrint(DefaultCommandLineCompiler.ja
va:104)
        at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.compile(DefaultCommandLineCompiler.java:94)

        at com.google.common.css.compiler.commandline.DefaultCommandLineCompiler.execute(DefaultCommandLineCompiler.java:129
)
        at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.executeJob(ClosureCommandLineCompiler.java:
290)
        at com.google.common.css.compiler.commandline.ClosureCommandLineCompiler.main(ClosureCommandLineCompiler.java:356)
Caused by: com.google.common.css.compiler.ast.ParseException: Encountered " <S> " 
"" at line 2, column 22.
Was expecting:
    <NUMBER> ...

        at com.google.common.css.compiler.ast.GssParserCC.generateParseException(GssParserCC.java:3756)
        at com.google.common.css.compiler.ast.GssParserCC.jj_consume_token(GssParserCC.java:3635)
        at com.google.common.css.compiler.ast.GssParserCC.term(GssParserCC.java:1562)
        at com.google.common.css.compiler.ast.GssParserCC.slash_term(GssParserCC.java:1494)
        at com.google.common.css.compiler.ast.GssParserCC.assign_term(GssParserCC.java:1446)
        at com.google.common.css.compiler.ast.GssParserCC.composite_term(GssParserCC.java:1397)
        at com.google.common.css.compiler.ast.GssParserCC.expr(GssParserCC.java:1379)
        at com.google.common.css.compiler.ast.GssParserCC.function(GssParserCC.java:2092)
        at com.google.common.css.compiler.ast.GssParserCC.term(GssParserCC.java:1682)
        at com.google.common.css.compiler.ast.GssParserCC.slash_term(GssParserCC.java:1494)
        at com.google.common.css.compiler.ast.GssParserCC.assign_term(GssParserCC.java:1446)
        at com.google.common.css.compiler.ast.GssParserCC.composite_term(GssParserCC.java:1397)
        at com.google.common.css.compiler.ast.GssParserCC.expr(GssParserCC.java:1370)
        at com.google.common.css.compiler.ast.GssParserCC.standardDeclaration(GssParserCC.java:1335)
        at com.google.common.css.compiler.ast.GssParserCC.styleDeclaration(GssParserCC.java:1193)
        at com.google.common.css.compiler.ast.GssParserCC.ruleSet(GssParserCC.java:463)
        at com.google.common.css.compiler.ast.GssParserCC.block(GssParserCC.java:2856)
        at com.google.common.css.compiler.ast.GssParserCC.start(GssParserCC.java:2903)
        at com.google.common.css.compiler.ast.GssParserCC.parse(GssParserCC.java:174)
        ... 6 more


What version of the product are you using? On what operating system?

Latest from git, windows 7.

Please provide any additional information below.

option 
--allowed_non_standard_function calc() 
won't help.


Reported by alexeykofficial on 2013-10-11 09:49:30

Support for CSS Media Types

Originally reported on Google Code with ID 10

What steps will reproduce the problem?
1. whenever css media type is used, parser is throwing GssParserException 
2. Reference http://www.w3schools.com/css/css_mediatypes.asp
3. Input

---
@media print{ html {  background:#fff; } }

---

What is the expected output?
@media print{html{background:#fff;}}

What version of the product are you using? On what operating system?
closure-stylesheets-20111215.jar, Windows XP Professional

Please provide any additional information below.


Reported by palam.c on 2011-12-23 08:38:24

minification looses trailing space in content:"> "

Originally reported on Google Code with ID 32

What steps will reproduce the problem?
1. create a one-line css file "bug.css", containing only the following line:
    LI.trail:before { content: "> "; }
2. run losure-stylesheets as follows:
    java -jar closure-stylesheets.jar bug.css
3. get the following output:
    LI.trail:before{content:"\00003e "}

There are several issues with the output:
- The space after "\00003e" needs to be doubled.  See section 4.1.4
  of http://www.w3.org/TR/CSS21/syndata.html for reference:

    Only one white space character is ignored after a hexadecimal
    escape. Note that this means that a "real" space after the escape
    sequence must be doubled.

  This problem causes html pages using the minified style sheet
  to render differently from pages which use the original style sheet.
- The trailing zeros in "\00003e" seem unnecessary.  Four characters
  could be saved by writing "\3e" instead.
- Does the ">" need escaping at all?

The problem is present in current git (commit id
86bb800d79a32bfc0328bbf74bfeb772c6eb73b0)

I hope this helps,
Jochen


Reported by jochen.voss on 2013-03-22 15:17:14

parser error for line like " background: qlineargradient(x1:1, y1:0, x2:0, y2:0, stop: 0 COLOR8, stop: 1 COLOR6);"

Originally reported on Google Code with ID 16

I am using css with Qt, I have a css as follow:
 QSlider::sub-page:horizontal
 {
   background: qlineargradient(x1:1, y1:0, x2:0, y2:0, stop: 0 COLOR8, stop: 1 COLOR6);
   margin-top: 5px; 
   margin-bottom: 5px; 
 }
COLOR8 and COLOR6 are defined already.
The parser has errors as follow:
Compiler parsing error: Parse error in ShivaQt.gss at line 150 column 35:
   background: qlineargradient(x1:1, y1:0, x2:0, y2:0, stop: 0 COLOR8, stop: 1 COLOR6);
                                  ^

com.google.common.css.compiler.ast.GssParserException: Parse error in ShivaQt.gss at
line 150 column 35:
   background: qlineargradient(x1:1, y1:0, x2:0, y2:0, stop: 0 COLOR8, stop: 1 COLOR6);

I used option " --allow-unrecognized-functions" but not works. I only want the closure-stylesheets
pars "COLOR8" and "COLOR6" for me, the version I use is closure-stylesheets-20111230.jar.

Is there any other way I can avoid this issue or it is a limitation currently for such
function "qlineargradient" from Qt?

Reported by machangan0514 on 2012-04-05 08:02:12

Parse error: -webkit-filter: drop-shadow

Originally reported on Google Code with ID 29

a {
  -webkit-filter: drop-shadow(0 1px 1px #000);
}

Compiler parsing error: Parse error in .....gss at line 1819 column 47:
  -webkit-filter: drop-shadow(0 1px 1px #000);

Compiler flags:
--allow-unrecognized-properties
--allow-unrecognized-functions

Reported by red.scorpix on 2012-10-12 13:59:20

Parsing Execption when combining multiple media queries features

The following media query produces a parsing exception

@media screen and (color),(max-width: 60em) {
  .stuff {
    background-color: red;
  }
}
com.google.common.css.compiler.ast.GssParserException: Parse error in /../../style.css at line 1 column 26:
@media screen and (color), (max-width: 60em) {
                         ^

Caused by: com.google.common.css.compiler.ast.ParseException: Encountered " "," ", "" at line 1, column 26.
Was expecting one of:

As far as I know it should be valid css.
I'm using 20140426

Patch for /src/com/google/common/css/compiler/ast/Property.java

Originally reported on Google Code with ID 15

Added support for some new CSS Properties for text(from the W3C Working Draft)

Reported by blub201087 on 2012-03-24 21:12:10


- _Attachment: [Property.java.patch](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-15/comment-0/Property.java.patch)_

Default Mixin Argument Values

Originally reported on Google Code with ID 3

Would like to be able to have default mixin argument values:

{{{
@defmixin roundedBorder(SIZE = 3px) {
    -moz-border-radius: SIZE;
    -webkit-border-radius: SIZE;
    border-radius: SIZE;
}
}}}

Reported by Zoramite on 2011-11-15 20:38:49

ant task for stylesheet clouser

Originally reported on Google Code with ID 6

Add customer ant task for building css from one or more gss source file.

similar solution exists for javascript closure.

http://code.google.com/p/closure-compiler/wiki/BuildingWithAnt

Reported by songyunhui2008 on 2011-11-22 02:48:23

Renaming can rename to a class already used

Originally reported on Google Code with ID 27

What steps will reproduce the problem?
1. pick a stylesheet
2. somewhere in that stylesheet put a class called 'a'
3. put a in --exluded-classes-from-renaming

What is the expected output? What do you see instead?

it is expected that no class will be renamed to 'a' as it is already in use

What version of the product are you using? On what operating system?

the latest

Please provide any additional information below.

came across this when adblock was hiding our site because 'body' was being renamed
to 'Ad' which was in the filters. Tried creating a class called 'Ad' but that was being
renamed and body was still 'Ad' so added it to the exclude renaming but would be worse
as 'body' was still 'Ad' and now we have two class definitions for 'Ad'


Reported by rhysbrettbowen on 2012-08-31 21:02:46

Handle windows UTF8 BOM character

Originally reported on Google Code with ID 13

What steps will reproduce the problem?
1. Try to compile a file with windows UFT8 + BOM encoding and crash

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
20111230

Please provide any additional information below.
Try to compiled attached (UTF8 + BOM) and you will see it reproduced.

Reported by guido.tapia on 2012-03-09 19:32:38


- _Attachment: [theme2.gss](https://storage.googleapis.com/google-code-attachments/closure-stylesheets/issue-13/comment-0/theme2.gss)_

Publish on Maven Central Repo

Originally reported on Google Code with ID 1

In order to easier adoption of the library, please publish it in maven central repo
(same as closure compiler).

Thanks,
Alex

Reported by alex.objelean on 2011-11-13 09:08:17

use "stylesheets-20111230.jar" find a bug.

Originally reported on Google Code with ID 23

What steps will reproduce the problem?
1. source file:
body{border: 1px blue solid;}
#id{
    width: 10px;
    height: 20px;
}body{border: 1px blue solid;}
#id2{
    width: 10px;
    height: 20px;
}body{border: 1px blue solid;}
#id3{
    width: 10px;
    height: 20px;
}
out-file:
#id,#id2{width:10px;height:20px}body{border:1px blue solid}#id3{width:10px;height:20px}


What is the expected output? What do you see instead?
expected :: #id,#id2,#id3{width:10px;height:20px}body{border:1px blue solid}

What version of the product are you using? On what operating system?
:: use stylesheets-20111230.jar



Reported by weirhp on 2012-06-27 06:47:59

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.