Skip to content

Commit

Permalink
fix ap#140
Browse files Browse the repository at this point in the history
Support non-percent saturation/luminance & whiteness/blackness in SASS and SCSS but prevent them in standard CSS
  • Loading branch information
adamhotep committed May 30, 2023
1 parent 1db0b4d commit a6846bf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions autoload/css_color.vim
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ function! s:hsl2rgb(h,u,s,l)
return rgb
endfunction

" vet hsl and hwb values
function! s:pctvet(h,s,l)
" for hsl & hwb, hue cannot be a percent, the others must be percents.
if a:h =~ "%$" || a:s !~ "%$" || a:l !~ "%$"
" hue cannot be a percent, others must be percents (except for sass & scss)
if a:h =~ "%$" || b:current_syntax !~ "s[ac]ss$" && (a:s !~ "%$" || a:l !~ "%$")
return [s:_invalid, s:_invalid, s:_invalid]
endif
let [s,l] = map( [a:s, a:l], 'v:val >= 100 ? 1.0 : v:val / 100.0' )
Expand Down
2 changes: 1 addition & 1 deletion tests/example.sass
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ s
!color1 = #359
!color2 = #335599
!color3 = rgba(144, 0, 0, .5)
!color4 = hsl(0, 100%, 50%)
!color4 = hsl(0, 100, 50)

/*
* #123, #456
Expand Down
2 changes: 1 addition & 1 deletion tests/example.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ s { background: hsl(0, 100%, 50%) }
$color1: #359;
$color2: #335599;
$color3: rgba(144, 0, 0, .5);
$color4: hsl(0, 100%, 50%);
$color4: hsl(0, 100, 50);

/*
* #123, #456
Expand Down

0 comments on commit a6846bf

Please sign in to comment.