refactor @ warn and @ debug parsing

This commit is contained in:
ConnorSkees 2020-04-06 00:13:15 -04:00
parent 44ff1c99b3
commit f0c1d508e6

View File

@ -62,21 +62,28 @@ impl AtRule {
return Err(message.to_string().into());
}
AtRuleKind::Warn => {
let message = toks
.take_while(|x| x.kind != ';')
.map(|x| x.kind.to_string())
.collect::<String>();
let message = Value::from_vec(
read_until_semicolon_or_closing_curly_brace(toks),
scope,
super_selector,
)?;
if toks.peek().unwrap().kind == ';' {
toks.next();
}
devour_whitespace(toks);
AtRule::Warn(pos, message)
AtRule::Warn(pos, message.to_string())
}
AtRuleKind::Debug => {
let message = toks
.by_ref()
.take_while(|x| x.kind != ';')
.map(|x| x.kind.to_string())
.collect::<String>();
let message = Value::from_vec(
read_until_semicolon_or_closing_curly_brace(toks),
scope,
super_selector,
)?;
if toks.peek().unwrap().kind == ';' {
toks.next();
}
devour_whitespace(toks);
AtRule::Debug(pos, message)
AtRule::Debug(pos, message.to_string())
}
AtRuleKind::Mixin => {
let (name, mixin) = Mixin::decl_from_tokens(toks, scope, super_selector)?;