interpolation in multiline comments

This commit is contained in:
ConnorSkees 2020-04-18 21:01:12 -04:00
parent 71546d7fc4
commit cb8be064a9
2 changed files with 18 additions and 3 deletions

View File

@ -553,8 +553,8 @@ pub(crate) fn read_until_newline<I: Iterator<Item = Token>>(toks: &mut Peekable<
/// TODO: support interpolation within multiline comments
pub(crate) fn eat_comment<I: Iterator<Item = Token>>(
toks: &mut Peekable<I>,
_scope: &Scope,
_super_selector: &Selector,
scope: &Scope,
super_selector: &Selector,
) -> SassResult<Spanned<String>> {
let mut comment = String::new();
let mut span = if let Some(tok) = toks.peek() {
@ -567,6 +567,11 @@ pub(crate) fn eat_comment<I: Iterator<Item = Token>>(
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);
}

View File

@ -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"
);