escape all symbols and whitespace

This commit is contained in:
ConnorSkees 2020-03-24 13:36:39 -04:00
parent 29166900d2
commit 6d2d9bcb4a

View File

@ -349,14 +349,11 @@ impl Value {
TokenKind::Symbol(Symbol::BackSlash) => {
if let Some(tok) = toks.next() {
match tok.kind {
TokenKind::Symbol(Symbol::Plus) => Ok(Value::Ident(
"\\+".to_string() + &flatten_ident(toks, scope, super_selector)?,
QuoteKind::None,
)),
TokenKind::Symbol(Symbol::BackSlash) => Ok(Value::Ident(
"\\\\".to_string() + &flatten_ident(toks, scope, super_selector)?,
TokenKind::Symbol(s) => Ok(Value::Ident(
format!("\\{}{}", s, flatten_ident(toks, scope, super_selector)?),
QuoteKind::None,
)),
TokenKind::Whitespace(w) => Ok(Value::Ident(format!("\\{}", w), QuoteKind::None)),
TokenKind::Ident(s) => Ok(Value::Ident(s, QuoteKind::None)),
_ => todo!("value after \\"),
}