From cb8be064a98d84a8e1f8cc3b861a2e013845e571 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 18 Apr 2020 21:01:12 -0400 Subject: [PATCH] interpolation in multiline comments --- src/utils.rs | 9 +++++++-- tests/comments.rs | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 46ecb08..75b23bc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -553,8 +553,8 @@ pub(crate) fn read_until_newline>(toks: &mut Peekable< /// TODO: support interpolation within multiline comments pub(crate) fn eat_comment>( toks: &mut Peekable, - _scope: &Scope, - _super_selector: &Selector, + scope: &Scope, + super_selector: &Selector, ) -> SassResult> { let mut comment = String::new(); let mut span = if let Some(tok) = toks.peek() { @@ -567,6 +567,11 @@ pub(crate) fn eat_comment>( if tok.kind == '*' && toks.peek().unwrap().kind == '/' { toks.next(); break; + } else if tok.kind == '#' && toks.peek().unwrap().kind == '{' { + toks.next(); + comment + .push_str(&parse_interpolation(toks, scope, super_selector)?.to_css_string(span)?); + continue; } comment.push(tok.kind); } diff --git a/tests/comments.rs b/tests/comments.rs index b535bfa..409239f 100644 --- a/tests/comments.rs +++ b/tests/comments.rs @@ -49,7 +49,17 @@ test!( "a {\n /* \n*/\n color: red;\n}\n" ); test!( - converts_cr_in_comment, + closing_curly_brace_in_comment, "a {\n color: 1 + // flang }\n blang }", "a {\n color: 1blang;\n}\n" ); +test!( + converts_cr_in_comment, + "a {\n /* \r*/ color: red;\n}\n", + "a {\n /* \n*/\n color: red;\n}\n" +); +test!( + interpolation_in_multiline_comment, + "$a: foo;/* interpolation #{1 + 1} in #{$a} comments */", + "/* interpolation 2 in foo comments */\n" +);