@@ -138,21 +138,17 @@ function! s:create_syn_match()
138
138
let rgb_color = get ( s: pattern_color , pattern, ' ' )
139
139
140
140
if ! strlen ( rgb_color )
141
- let hexcolor = submatch (1 )
141
+ let hex = submatch (1 )
142
142
let funcname = submatch (2 )
143
143
144
- if funcname == ' rgb'
145
- let rgb_color = s: rgb2color (submatch (3 ),submatch (4 ),submatch (5 ))
146
- elseif funcname == ' hsl'
147
- let rgb_color = s: hsl2color (submatch (3 ),submatch (4 ),submatch (5 ))
148
- elseif strlen (hexcolor) == 6
149
- let rgb_color = tolower (hexcolor)
150
- elseif strlen (hexcolor) == 3
151
- let rgb_color = substitute (tolower (hexcolor), ' \(.\)' , ' \1\1' , ' g' )
152
- else
153
- throw ' css_color: create_syn_match invoked on bad match data'
154
- endif
144
+ let rgb_color
145
+ \ = funcname == ' rgb' ? s: rgb2color (submatch (3 ),submatch (4 ),submatch (5 ))
146
+ \ : funcname == ' hsl' ? s: hsl2color (submatch (3 ),submatch (4 ),submatch (5 ))
147
+ \ : strlen (hex) == 6 ? tolower (hex)
148
+ \ : strlen (hex) == 3 ? tolower (hex[0 ].hex[0 ].hex[1 ].hex[1 ].hex[2 ].hex[2 ])
149
+ \ : ' '
155
150
151
+ if rgb_color == ' ' | throw ' css_color: create_syn_match invoked on bad match data' | endif
156
152
let s: pattern_color [pattern] = rgb_color
157
153
endif
158
154
@@ -202,7 +198,7 @@ function! s:create_matches()
202
198
endfor
203
199
endfunction
204
200
205
- let s: _hexcolor = ' #\(\x\{3}\|\x\{6}\)\> ' " submatch 1
201
+ let s: _hexcolor = ' #\(\x\{3}\%(\>\ |\x\{3}\>\)\) ' " submatch 1
206
202
let s: _funcname = ' \(rgb\|hsl\)a\?' " submatch 2
207
203
let s: _ws_ = ' \s*'
208
204
let s: _numval = s: _ws_ . ' \(\d\{1,3}%\?\)' " submatch 3,4,5
0 commit comments