diff --git a/src/parse/args.rs b/src/parse/args.rs index adad512..ea22cc4 100644 --- a/src/parse/args.rs +++ b/src/parse/args.rs @@ -7,7 +7,10 @@ use crate::{ common::QuoteKind, error::SassResult, scope::Scope, - utils::{peek_ident_no_interpolation, peek_whitespace_or_comment, read_until_closing_paren}, + utils::{ + peek_ident_no_interpolation, peek_whitespace_or_comment, read_until_closing_paren, + read_until_closing_quote, read_until_newline, + }, value::Value, Token, }; @@ -67,6 +70,27 @@ impl<'a> Parser<'a> { default.push(self.toks.next().unwrap()); default.extend(read_until_closing_paren(self.toks)?); } + '/' => { + let next = self.toks.next().unwrap(); + match self.toks.peek() { + Some(Token { kind: '/', .. }) => read_until_newline(self.toks), + _ => default.push(next), + }; + continue; + } + q @ '"' | q @ '\'' => { + let q = *q; + default.push(self.toks.next().unwrap()); + default.extend(read_until_closing_quote(self.toks, q)?); + continue; + } + '\\' => { + default.push(self.toks.next().unwrap()); + default.push(match self.toks.next() { + Some(tok) => tok, + None => continue, + }); + } _ => default.push(self.toks.next().unwrap()), } } diff --git a/tests/args.rs b/tests/args.rs index adde390..6d5f356 100644 --- a/tests/args.rs +++ b/tests/args.rs @@ -187,3 +187,14 @@ test!( }", "a {\n color: kwd-y;\n}\n" ); +test!( + quoted_string_as_default_argument_value, + r#"@function foo($font-family: 'Roboto, "Helvetica Neue", sans-serif') { + @return $font-family; + } + + a { + color: foo(); + }"#, + "a {\n color: 'Roboto, \"Helvetica Neue\", sans-serif';\n}\n" +);