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

colors.isColor and colors.parseColor do not recognize "LightGrey" #19124

Closed
orthoplex opened this issue Nov 11, 2021 · 4 comments
Closed

colors.isColor and colors.parseColor do not recognize "LightGrey" #19124

orthoplex opened this issue Nov 11, 2021 · 4 comments

Comments

@orthoplex
Copy link
Contributor

Example

import colors
echo colors.isColor("LightGrey")
echo colors.parseColor("LightGrey")

Current Output

false
/home/orthoplex/nimbug/bug.nim(3) bug
/usr/lib/nim/pure/colors.nim(456) parseColor
Error: unhandled exception: unknown color: LightGrey [ValueError]

Expected Output

true
#D3D3D3

Solution

Both procedures perform a binary search on colorNames, which is not sorted correctly.
To fix this, "lightgrey" and "lightgreen" need to be swapped.

@orthoplex
Copy link
Contributor Author

Pull Request: #19125

@GrayJoKing
Copy link

This technically "fixes" the issue, but it probably should have instead been renamed to the American spelling "lightgray" in order to match with the rest of the gray colours. This module as a whole should also be updated to fully follow the CSS colours standard, which includes both spellings as aliases (additionally, a couple of the colour codes are incorrect, with 8s swapped out for Bs)

@Araq
Copy link
Member

Araq commented Nov 29, 2021

Please produce a follow-up PR.

@orthoplex
Copy link
Contributor Author

I deliberately did not rename the color to "lightgray" since that would also involve changing the corresponding constant name to colLightGray, which could break existing code. I think the most reasonable way to fix the naming inconsistency would be to introduce all variations of "grey" and "gray".

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

No branches or pull requests

3 participants