Skip to content

fix: handle 3-digit shorthand hex in hex_to_rgb#5662

Open
genrichez wants to merge 1 commit into
plotly:mainfrom
genrichez:fix-hex-to-rgb-shorthand
Open

fix: handle 3-digit shorthand hex in hex_to_rgb#5662
genrichez wants to merge 1 commit into
plotly:mainfrom
genrichez:fix-hex-to-rgb-shorthand

Conversation

@genrichez

Copy link
Copy Markdown

Closes #5661.

hex_to_rgb assumed the input was always 6 digits. 3-digit shorthand like #FFF was parsed as (15, 15, 15 ) instead of (255, 255, 255).

Fix: expand 3-char codes to 6-char before slicing (e.g. FFF). Applied to both copies in _plotly_utils/colors and plotly/matplotlylib/mpltools.

Added tests for the shorthand case.

Expand 3-char hex codes (e.g. #FFF) to 6-char before parsing.
Fixes both _plotly_utils and matplotlylib copies.

Closes plotly#5661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: hex_to_rgb misparses 3-digit shorthand hex colors (#FFF -> (15,15,15))

1 participant