Consume whitespace after variable value
This commit is contained in:
parent
cee40858ee
commit
eaf1e8eb96
@ -714,6 +714,11 @@ mod css_variables {
|
||||
"$a: 1px;\n$b: 1 $a;\na {\n height: $b;\n}\n",
|
||||
"a {\n height: 1 1px;\n}\n"
|
||||
);
|
||||
test!(
|
||||
eats_whitespace_after_variable_value,
|
||||
"a {\n b {\n $c: red;\n }\n color: red;\n}\n",
|
||||
"a {\n color: red;\n}\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
15
src/utils.rs
15
src/utils.rs
@ -75,21 +75,6 @@ pub fn eat_variable_value<I: Iterator<Item = Token>>(
|
||||
_ => iter2.push(tok),
|
||||
};
|
||||
}
|
||||
Ok(iter2)
|
||||
}
|
||||
|
||||
pub fn eat_variable_value_ref<'a, I: Iterator<Item = &'a Token>>(
|
||||
toks: &mut Peekable<I>,
|
||||
scope: &Scope,
|
||||
) -> Result<Vec<Token>, (Pos, &'static str)> {
|
||||
devour_whitespace(toks);
|
||||
let iter1 = toks.take_while(|x| x.kind != TokenKind::Symbol(Symbol::SemiColon));
|
||||
let mut iter2 = Vec::new();
|
||||
for tok in iter1 {
|
||||
match tok.kind {
|
||||
TokenKind::Variable(ref name) => iter2.extend(deref_variable(name, scope)),
|
||||
_ => iter2.push(tok.clone()),
|
||||
};
|
||||
}
|
||||
Ok(iter2)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user