diff --git a/src/parse/media.rs b/src/parse/media.rs index 606c27c..2a0c036 100644 --- a/src/parse/media.rs +++ b/src/parse/media.rs @@ -1,6 +1,9 @@ use crate::{ error::SassResult, - utils::{is_name_start, peek_ident_no_interpolation, read_until_closing_paren}, + utils::{ + is_name_start, peek_ident_no_interpolation, read_until_closing_paren, + read_until_closing_quote, + }, {Cow, Token}, }; @@ -61,13 +64,18 @@ impl<'a> Parser<'a> { '>' | '<' | ':' | ')' => { break; } + '\'' | '"' => { + toks.push(tok); + self.toks.next(); + toks.append(&mut read_until_closing_quote(self.toks, tok.kind)?); + } _ => { toks.push(tok); self.toks.next(); } } } - self.parse_value_as_string_from_vec(toks) + self.parse_value_as_string_from_vec(toks, false) } pub(super) fn parse_media_query_list(&mut self) -> SassResult { @@ -112,7 +120,7 @@ impl<'a> Parser<'a> { todo!() } } - buf.push_str(&self.parse_value_as_string_from_vec(toks)?); + buf.push_str(&self.parse_value_as_string_from_vec(toks, true)?); self.whitespace(); buf.push(')'); diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 5377fa1..825baca 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -435,9 +435,14 @@ impl<'a> Parser<'a> { pub fn parse_value_as_string_from_vec( &mut self, toks: Vec, + quoted: bool, ) -> SassResult> { let value = self.parse_value_from_vec(toks)?; - value.node.to_css_string(value.span) + if quoted { + value.node.to_css_string(value.span) + } else { + value.node.unquote().to_css_string(value.span) + } } pub fn whitespace(&mut self) -> bool { diff --git a/tests/media.rs b/tests/media.rs index e2f6282..3b70082 100644 --- a/tests/media.rs +++ b/tests/media.rs @@ -54,3 +54,12 @@ test!( "@media (color) {a {color: red;}}", "@media (color) {\n a {\n color: red;\n }\n}\n" ); +test!( + quoted_colon_in_parens, + "@media screen and (\":\") { + a { + color: red; + } + }", + "@media screen and (:) {\n a {\n color: red;\n }\n}\n" +);