Open 5e-Cleric opened 9 months ago
It's not the spaces or the quoting that is breaking.
It is the +
in the calc.
This works (because subtracting a negative is addition):
{{background:lightgreen,height:"calc(57px - -3px)"
GREEN
}}
Other math operators also break e.g. *
/
.
Find the regex — I think it was written with the anticipation of negative numbers being allowed (e.g. margin: -4px
), but not with the assumption there would be operators like +
, -
, *
etc.
Noted, the bug still exists, but if its only a regex error then it is an easy fix.
In each regex there is a pair of patterns [\w\-()$%]
that needs to be expanded to [\w,\-+*\/()#%. ]
https://regex101.com/r/exp6WA/2
We only need to add +
, /
, *
, according to the css spec
https://developer.mozilla.org/en-US/docs/Web/CSS/calc
Probably should also fix editor.jsx (for highlighting) and mustache-syntax.test.js (for unit tests).
Other math operators also break e.g.
*
/
.
Technically, the *
and /
operators don't need to have spaces (unlike addition and subtraction operators), and so this form does work:
{{background:lightgreen,height:calc(57px*3) TEXT}}
{{background:lightgreen,height:calc(57px/3) TEXT}}
That is, no spaces around the operators, and no quoting of the property value.
If you don't mind, gonna give you some Calc operations i know already work, to make sure this works:
calc(400px/(10 + (tan(30deg)/3)*2))
calc((10dvh - 10pc)*(sin(200)/pi))
If you don't mind, gonna give you some Calc operations i know already work, to make sure this works:
calc(400px/(10 + (tan(30deg)/3)*2))
calc((10dvh - 10pc)*(sin(200)/pi))
new regex works with them: https://regex101.com/r/exp6WA/2
Right now, the curly syntax for the
calc()
function, breaks because the RegEx pattern does not expect mathematical symbols.This brew should work as an example: https://homebrewery.naturalcrit.com/share/oDUY9Cl2cDd6
Preview for later/ if the brew was deleted: