From a6b61082fe6298d24dad98770d7e9408bc6d9583 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 20 Apr 2020 12:12:39 -0400 Subject: [PATCH] interpolation of strings in idents is literal --- src/utils.rs | 7 ++++--- src/value/mod.rs | 12 ++++-------- tests/interpolation.rs | 5 +++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 5ab102f..f48bc74 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -525,9 +525,10 @@ pub(crate) fn eat_ident>( if kind == &'{' { toks.next(); text.push_str( - &parse_interpolation(toks, scope, super_selector)? - .node - .to_css_string(span)?, + &match parse_interpolation(toks, scope, super_selector)?.node { + Value::Ident(s, ..) => s, + v => v.to_css_string(span)?, + }, ); } else { return Err(("Expected identifier.", *pos).into()); diff --git a/src/value/mod.rs b/src/value/mod.rs index d761bf8..eb27267 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -165,14 +165,10 @@ impl Value { let mut buf = String::with_capacity(string.len()); for c in string.chars() { match c { - // TODO: figure out what is going on here - // This is adapted from the original dart-sass - // code, but in the spec tests it seems that - // newlines are not actually treated like this. - // '\n' => { - // buf.push(' '); - // after_newline = true; - // } + '\n' => { + buf.push(' '); + after_newline = true; + } ' ' => { if !after_newline { buf.push(' '); diff --git a/tests/interpolation.rs b/tests/interpolation.rs index c51d7f2..1bfce7e 100644 --- a/tests/interpolation.rs +++ b/tests/interpolation.rs @@ -53,3 +53,8 @@ test!( "a {\n color: \"#{#{\"\\a\"}}\";\n}\n", "a {\n color: \"\\a\";\n}\n" ); +test!( + interpolated_quoted_newline, + "a {\n color: #{\"\\a\"};\n}\n", + "a {\n color: ;\n}\n" +);