@@ -567,7 +567,7 @@ end --}}}
567
567
---- ---------------------------------
568
568
569
569
local function detect_colors (str ) -- {{{
570
- local hex_pattern = " #%x%x%x%x%x%x %x?%x?"
570
+ local hex_pattern = " #%x%x%x%x?%x?%x? %x?%x?"
571
571
local rgb_pattern = " rgba?%(%s*%d+%s*,%s*%d+%s*,%s*%d+%s*.*%)"
572
572
local hsl_pattern = " hsla?%(%s*%d+%s*,%s*%d+%s*%%*,%s*%d+%s*%%*.*%)"
573
573
@@ -633,13 +633,15 @@ end --}}}
633
633
local function sandwich_processor (str ) -- {{{
634
634
local hex_capture_pattern = " #(%x%x%x%x%x%x)"
635
635
local hexa_capture_pattern = " #(%x%x%x%x%x%x)(%x%x)"
636
+ local short_hex_capture_pattern = " #(%x%x%x)"
636
637
local rgba_capture_pattern = " rgba%(%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*,?%s*(%d+%.?%d*)%s*%)"
637
638
local hsla_capture_pattern = " hsla%(%s*(%d+)%s*,%s*(%d+)%s*%%*,%s*(%d+)%s*%%,?%s*(%d+%.?%d*)%s*%)"
638
639
local rgb_capture_pattern = " rgb%(%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*,?%s*%)"
639
640
local hsl_capture_pattern = " hsl%(%s*(%d+)%s*,%s*(%d+)%s*%%*,%s*(%d+)%s*%%,?%s*%)"
640
641
641
642
local _ , _ , hex_val , hex_trans = string.find (str , hexa_capture_pattern )
642
643
local _ , _ , hex = string.find (str , hex_capture_pattern )
644
+ local _ , _ , short_hex = string.find (str , short_hex_capture_pattern )
643
645
local _ , _ , ra , ga , ba , rgba = string.find (str , rgba_capture_pattern )
644
646
local _ , _ , ha , sa , la , hsla = string.find (str , hsla_capture_pattern )
645
647
local _ , _ , r , g , b = string.find (str , rgb_capture_pattern )
@@ -648,6 +650,11 @@ local function sandwich_processor(str) --{{{
648
650
return { " hex" , hex_val , hex_trans }
649
651
elseif hex then
650
652
return { " hex" , hex }
653
+ elseif short_hex then
654
+ local red = short_hex :sub (1 , 1 )
655
+ local green = short_hex :sub (2 , 2 )
656
+ local blue = short_hex :sub (3 , 3 )
657
+ return { " hex" , red .. red .. green .. green .. blue .. blue }
651
658
elseif ra then
652
659
return { " rgb" , tonumber (ra ), tonumber (ga ), tonumber (ba ), tonumber (rgba ) }
653
660
elseif ha then
0 commit comments