From f0c1d508e6d55fe9a96d79ae18d415498370eae8 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 6 Apr 2020 00:13:15 -0400 Subject: [PATCH] refactor @ warn and @ debug parsing --- src/atrule/mod.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/atrule/mod.rs b/src/atrule/mod.rs index 1b26a5f..891a42e 100644 --- a/src/atrule/mod.rs +++ b/src/atrule/mod.rs @@ -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::(); + 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::(); + 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)?;