cssutils icon indicating copy to clipboard operation
cssutils copied to clipboard

Hex Colors Being Shortened During parseString()

Open nat0321 opened this issue 2 years ago • 1 comments

I was using cssutils to pull color data from a website and came across what I believe to be a bug.

Test Code:

test = ".auto-style5 { width: 250px; color: #FFFFFF; background-color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: x-large; }"
css = cssutils.parseString(test)
for rule in css:
    print(rule)

Result:

<cssutils.css.CSSStyleRule object selectorText='.auto-style5' style='width: 250px;\ncolor: #FFF;\nbackground-color: #000;\nfont-family: Arial, Helvetica, sans-serif;\nfont-size: x-large' _namespaces={} at 0x1063973a0>

color and background-color are shortened from #FFFFFF & #000000 to #FFF & #000 causing issues with my application.

nat0321 avatar Nov 28 '23 16:11 nat0321

I'm not familiar enough with hex codes. Are those codes equivalent?

Doing a quick search, I did determine that those color codes are equivalent (if only three hex digits are supplied, it's inferred that the other digit of the longer form is the same).

What sorts of issues does this cause with your application?

jaraco avatar Mar 30 '24 16:03 jaraco