Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error when assigning a hex color value to the last attribute of a linkStyle #5498

Open
chrisbloom7 opened this issue May 2, 2024 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@chrisbloom7
Copy link

chrisbloom7 commented May 2, 2024

Description

As the title says, trying to assign a hexadecimal color value to the last attribute of a linkStyle definition causes a parsing error. For example:

graph LR
  A --> B

  %% Assigning a hex color to the last attribute, parsing error
  linkStyle 0 stroke-width:4px,stroke:#FF69B4;
graph LR
  A --> B

  linkStyle 0 stroke-width:4px,stroke:#FF69B4;

The parsing error does not occur when you assign a hex color value to an attribute that is not the last attribute, nor if you assign a color name instead of a hex value to the last attribute 🤯

graph LR
  A --> B
  C --> D

  %% Assigning a hex color to an attribute that isn't the the last, works OK
  linkStyle 0 stroke:#FF69B4,stroke-width:4px;

  %% Assigning a color name instead of a hex value to the last attribute, works OK
  linkStyle 1 stroke-width:4px,stroke:HotPink;
graph LR
  A --> B
  C --> D

  linkStyle 0 stroke:#FF69B4,stroke-width:4px;
  linkStyle 1 stroke-width:4px,stroke:HotPink;

Steps to reproduce

  1. Recreate the graph definitions above in a mermaid compatible editor
  2. View the rendered output
  3. Observe the first graph generates a parsing error while the second does not

Screenshots

Screenshot of the parsing error when rendered:

screenshot of parsing error

Code Sample

Setup

I've confirmed this behavior in both https://mermaid.live (as of v10.9.0) and https://develop.git.mermaid.live (as of v11.0.0-alpha.7+e68125e).

  • Chrome for OS X, Version 124.0.6367.93 (Official Build) (arm64)

Suggested Solutions

Based on the parsing error output, it appears to be an encoding problem while trying to parse the original hex value. I have verified that this is not a copy/paste issue from a corrupt source definition.

Parse error on line 4:
... linkStyle 0 stroke:fl°FF69B4¶ß
-----------------------^

Additional Context

No response

@chrisbloom7 chrisbloom7 added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels May 2, 2024
@chrisbloom7 chrisbloom7 changed the title Parsing error when assigning a hex value to an attribute of linkStyle when it's the last attribute Parsing error when assigning a hex color value to the last attribute of a linkStyle May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

1 participant