You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "LRein (Jira)" <ji...@apache.org> on 2023/04/06 17:52:00 UTC

[jira] [Created] (TAP5-2753) CssCompressor for CSS files produces wrong minification if calc contains variables.

LRein created TAP5-2753:
---------------------------

             Summary: 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


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)