#152
Support using css variables for inline styles?
Any chance that pele supports css variables for inline-styles?
It would be awesome to be able to style graph nodes with theme colors without explicit css snippets in obsidian, e.g.:
graph TD
A[Some Text]
style A fill:var(--color-red)
I looked into this and built a working fix, but I'm holding it because it needs a maintainer call first.
The problem is real: every parenthesized style value fails to parse.
(lexes as a shape opener (var(--x)turns(-into an ellipse start), and the style parser takes no parenthesized group, sorgb(1, 2, 3)is rejected too. The fix touches the lexer (treat(afterproperty:as a function call, not an ellipse —A(-text-)still draws an ellipse), the parser (style()consumes balanced paren groups), andaddClass(stop re-splitting declarations on commas, sovar(--x, #f00)survivesclassDef). 7 new tests, all passing with the fix, 6 of 7 failing on main;style,classDefandlinkStyleall take the values.The blocker: Mermaid's own grammar genuinely rejects these values too — its
styleComponenthas no paren token — and pele's oracle test enforces exact agreement with Mermaid, so landing this fix breaks CI. Supporting #152 is an intentional divergence from Mermaid, not a bug fix that stays inside the grammar.So the question for maintainers: do you want pele to diverge from Mermaid here? If yes, I'm happy to open the PR (prototype + tests ready) — just say how you'd like the oracle test updated to bless the divergence. If no, I'll close this out as declined and leave the prototype aside. One known limitation either way:
calc(1px + var(--w))still fails, since the inner(-lexes as an ellipse start.