You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Ben Weidig (Jira)" <ji...@apache.org> on 2023/06/26 07:49:00 UTC
[jira] [Resolved] (TAP5-2753) CssCompressor for CSS files produces wrong minification if calc contains variables.
[ https://issues.apache.org/jira/browse/TAP5-2753?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ben Weidig resolved TAP5-2753.
------------------------------
Fix Version/s: 5.8.3
Resolution: Fixed
> CssCompressor for CSS files produces wrong minification if calc contains variables.
> -----------------------------------------------------------------------------------
>
> Key: TAP5-2753
> URL: https://issues.apache.org/jira/browse/TAP5-2753
> Project: Tapestry 5
> Issue Type: Bug
> Components: tapestry-webresources
> Affects Versions: 5.8.2
> Reporter: LRein
> Assignee: Ben Weidig
> Priority: Minor
> Fix For: 5.8.3
>
>
> CssCompressor for CSS files produces wrong minification if calc contains variables.
> {code:css}
> .some-class
> {
> padding-top: calc(10px + var(--default-page-header-height));
> }
> {code}
> produces spaces between dashes within the variable:
> {code:css}
> .some-class
> {
> padding-top: calc(10px + var( - - default - page - header - height));
> }
> {code}
> Just removing this code block at the end helps:
> {code:java}
> // Add spaces back in between operators for css calc function
> // https://developer.mozilla.org/en-US/docs/Web/CSS/calc
> // Added by Eric Arnol-Martin (earnolmartin@gmail.com)
> sb = new StringBuffer();
> p = Pattern.compile("calc\\([^\\)]*\\)");
> m = p.matcher(css);
> while (m.find()) {
> String s = m.group();
>
> s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\+", " + ");
> s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\-", " - ");
> s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\*", " * ");
> s = s.replaceAll("(?<=[-|%|px|em|rem|vw|\\d]+)\\/", " / ");
>
> m.appendReplacement(sb, s);
> }
> m.appendTail(sb);
> css = sb.toString();
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)