diff --git a/src/builtin/string.rs b/src/builtin/string.rs index d9f6c17..034f6c7 100644 --- a/src/builtin/string.rs +++ b/src/builtin/string.rs @@ -49,6 +49,7 @@ pub(crate) fn register(f: &mut BTreeMap) { let str_len = string.len(); let start = match arg!(args, 1, "start-at").eval() { Value::Dimension(n, Unit::None) if n.to_integer().is_positive() => n.to_integer().to_usize().unwrap(), + Value::Dimension(n, Unit::None) if n == Number::from(0) => 1_usize, Value::Dimension(n, Unit::None) => (BigInt::from(str_len + 1) + n.to_integer()).to_usize().unwrap(), Value::Dimension(..) => todo!("$start: Expected ___ to have no units."), _ => todo!("$start-at: ____ is not a number") diff --git a/tests/strings.rs b/tests/strings.rs index 00f6872..e27b01b 100644 --- a/tests/strings.rs +++ b/tests/strings.rs @@ -63,3 +63,8 @@ test!( "a {\n color: str-slice(abcd, 2, -2);\n}\n", "a {\n color: bc;\n}\n" ); +test!( + str_slice_start_0, + "a {\n color: str-slice(cde, 0);\n}\n", + "a {\n color: cde;\n}\n" +);