Skip to content

Commit d97ab32

Browse files
authored
Merge pull request yui#245 from own3mall/master
Adds spaces to the operators for CSS calc functions.
2 parents f8519bb + e9e4381 commit d97ab32

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CVS/
1010
*#*#
1111
build/classes
1212
build/jar
13+
build/build_tmp
1314
build/yuicompressor*.jar
1415
.project
1516
.classpath

ant.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ lib.dir = lib
33
doc.dir = doc
44
build.dir = build
55
product.name = yuicompressor
6-
version.number = 2.4.8
6+
version.number = 2.4.9
77
jar.name = ${product.name}-${version.number}.jar
88
dist.package.name = ${product.name}-${version.number}

maven_central/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<project name="YUI Compressor bundle for Maven Central" default="maven-central-bundle" basedir=".">
3-
<property name="yui.version">2.4.8</property>
3+
<property name="yui.version">2.4.9</property>
44
<property name="rhino.version">1.7R2</property>
55

66
<target name="clean">

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "yuicompressor",
33
"description": "YUICompressor CLI and Node.js require",
4-
"version": "2.4.8",
4+
"version": "2.4.9",
55
"author": "Julien Lecomte <julien.lecomte@gmail.com>",
66
"contributors": [
77
{
@@ -13,6 +13,9 @@
1313
}, {
1414
"name" : "Stoyan Stefanov",
1515
"email" : "assttoo@ymail.com"
16+
}, {
17+
"name" : "Eric Arnol-Martin",
18+
"email" : "earnolmartin@gmail.com"
1619
}
1720
],
1821
"bugs": { "url" : "http://yuilibrary.com/projects/yuicompressor/newticket" },

src/com/yahoo/platform/yui/compressor/CssCompressor.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,25 @@ public void compress(Writer out, int linebreakpos)
501501
for(i = 0, max = preservedTokens.size(); i < max; i++) {
502502
css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens.get(i).toString());
503503
}
504+
505+
// Add spaces back in between operators for css calc function
506+
// https://developer.mozilla.org/en-US/docs/Web/CSS/calc
507+
// Added by Eric Arnol-Martin (earnolmartin@gmail.com)
508+
sb = new StringBuffer();
509+
p = Pattern.compile("calc\\([^\\)]*\\)");
510+
m = p.matcher(css);
511+
while (m.find()) {
512+
String s = m.group();
513+
514+
s = s.replaceAll("(?<=[%|px|em|rem|vw|\\d]+)\\+", " + ");
515+
s = s.replaceAll("(?<=[%|px|em|rem|vw|\\d]+)\\-", " - ");
516+
s = s.replaceAll("(?<=[%|px|em|rem|vw|\\d]+)\\*", " * ");
517+
s = s.replaceAll("(?<=[%|px|em|rem|vw|\\d]+)\\/", " / ");
518+
519+
m.appendReplacement(sb, s);
520+
}
521+
m.appendTail(sb);
522+
css = sb.toString();
504523

505524
// Trim the final string (for any leading or trailing white spaces)
506525
css = css.trim();

0 commit comments

Comments
 (0)