diff --git a/src/builtin/color/other.rs b/src/builtin/color/other.rs index 697d143..9446b65 100644 --- a/src/builtin/color/other.rs +++ b/src/builtin/color/other.rs @@ -92,11 +92,9 @@ pub(crate) fn register(f: &mut HashMap) { } let hue = match arg!(args, -1, "hue" = Value::Null) { - Value::Dimension(n, Unit::None) - | Value::Dimension(n, Unit::Percent) - | Value::Dimension(n, Unit::Deg) => Some(n), + Value::Dimension(n, _) => Some(n), Value::Null => None, - _ => todo!("expected either unitless or % number for hue"), + v => return Err(format!("$hue: {} is not a number.", v).into()), }; opt_hsl!(args, saturation, "saturation", -100, 100); @@ -177,22 +175,14 @@ pub(crate) fn register(f: &mut HashMap) { ))); } - let hue = match arg!(args, -1, "hue" = Value::Null) { - Value::Dimension(n, Unit::None) - | Value::Dimension(n, Unit::Percent) - | Value::Dimension(n, Unit::Deg) => Some(n), - Value::Null => None, - _ => todo!("expected either unitless or % number for hue"), - }; - opt_scale_arg!(args, saturation, "saturation", -100, 100); opt_scale_arg!(args, luminance, "lightness", -100, 100); - if hue.is_some() || saturation.is_some() || luminance.is_some() { + if saturation.is_some() || luminance.is_some() { // Color::as_hsla() returns more exact values than Color::hue(), etc. let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla(); return Ok(Value::Color(Color::from_hsla( - scale(this_hue, hue.unwrap_or(Number::from(0)), Number::from(360)), + scale(this_hue, Number::from(0), Number::from(360)), scale( this_saturation, saturation.unwrap_or(Number::from(0)), diff --git a/src/lexer.rs b/src/lexer.rs index 7ab604d..cd21171 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -303,6 +303,8 @@ impl<'a> Lexer<'a> { } } + // TODO: handle weird characters that *are* ascii + // e.g. how do we handle `color: ;` fn lex_ident(&mut self) -> TokenKind { let mut string = String::with_capacity(99); while let Some(c) = self.buf.peek() {