Skip to content

Commit cd952ab

Browse files
committed
ignore case in hex colors
1 parent 9a1c03d commit cd952ab

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/Resources/ui/js/ace.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plotdevice/gfx/colors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ def recognized(cls, blob):
300300
if isinstance(blob, Color):
301301
return True
302302

303-
valid_str = lambda s: isinstance(s, str) and (s.strip() in _CSS_COLORS or \
304-
re.match(r'#?[a-z0-9]{3,8}$', s.strip()) )
303+
def valid_str(s):
304+
s = s.strip() if isinstance(s, str) else ''
305+
return s in _CSS_COLORS or re.match(r'#?[A-Fa-f0-9]{3,8}$', s)
306+
305307
if isinstance(blob, (tuple, list)):
306308
demoded = [b for b in blob if b not in (RGB,HSV,CMYK,GREY)]
307309
if all(numlike(n) and len(demoded)<=5 for n in blob):
@@ -331,7 +333,7 @@ def _parse(cls, clrstr):
331333
if clrstr in _CSS_COLORS: # handle css color names
332334
clrstr = _CSS_COLORS[clrstr]
333335

334-
if re.search(r'#?[0-9a-f]{3,8}', clrstr): # rgb & rgba hex strings
336+
if re.search(r'#?[0-9a-fA-F]{3,8}', clrstr): # rgb & rgba hex strings
335337
hexclr = clrstr.lstrip('#')
336338
if len(hexclr) in (3,4):
337339
hexclr = "".join(map("".join, zip(hexclr,hexclr)))

0 commit comments

Comments
 (0)