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

Certain comments is breaking the parser and hex colours are converted to rgb colours #150

Open
Tig2r opened this issue May 11, 2023 · 3 comments

Comments

@Tig2r
Copy link

Tig2r commented May 11, 2023

I noticed that when I use EXCSS, when I have a comment with //, it won't apply the CSS class just below it.

I also noticed that it will convert hex colours to rgb colours. Is there a setting to disable this?

@lee-m
Copy link
Contributor

lee-m commented May 12, 2023

Colours are canonicalised to RGA{A} when ToString() is called on a parsed colour value and there's no way to configure that as far as I can tell.

You could try accessing the Original property instead of Value to get the value as it appeared in the parsed input.

@TylerBrinks
Copy link
Owner

We could consider preserving the original color, but I'm not sure I understand the value in doing so. Parsers like ExCSS generate an AST designed to normalize conventions into a single, common form. There is no informational difference between RGB, hex and well as other colors formats. For example, these 3 values are equivalent:

Hex: #DACA45;
RGB: rgb(218, 202, 69);
HSL: hsl(54, 67%, 56%);

It's a matter of personal preference. I tend to favor RGB since it can optionally include an alpha channel as a 4th parameter to handle opacity.

It's simple to convert RGB to hex. Take a look at the ExCSS code for examples. The hexidecimal format string makes conversion trivial:

$"{r:X2}{g:X2}{b:X2}"

@Tig2r
Copy link
Author

Tig2r commented May 24, 2023

The main reason for the requirement for Hex colours is because we use it to generate Inline CSS styling for newsletter templates. Some older email clients like Outlook doesn’t support rgb or rgba.

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