From 2a3f13bea0129c172cbc8fa28b0d492e94f87b88 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 29 Mar 2020 23:00:39 -0400 Subject: [PATCH] allow escaped quotes to start idents --- src/utils.rs | 10 +++++++++- tests/misc.rs | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 2e69384..5c7524d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -224,6 +224,10 @@ pub(crate) fn read_until_semicolon_or_closing_curly_brace { break; } + '\\' => { + t.push(toks.next().unwrap()); + t.push(toks.next().unwrap()); + } '"' | '\'' => { let quote = toks.next().unwrap(); t.push(quote.clone()); @@ -258,6 +262,10 @@ pub(crate) fn read_until_semicolon_or_open_or_closing_curly_brace { break; } + '\\' => { + t.push(toks.next().unwrap()); + t.push(toks.next().unwrap()); + } '"' | '\'' => { let quote = toks.next().unwrap(); t.push(quote.clone()); @@ -306,7 +314,7 @@ pub(crate) fn eat_variable_value>( let mut raw = read_until_semicolon_or_closing_curly_brace(toks) .into_iter() .peekable(); - if toks.peek().unwrap().kind == ';' { + if toks.peek().is_some() && toks.peek().unwrap().kind == ';' { toks.next(); } let mut x = Vec::new(); diff --git a/tests/misc.rs b/tests/misc.rs index dfccddb..b2f6034 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -87,3 +87,7 @@ test!( does_not_combine_idents_with_leading_hyphen_all, "a {\n color: -a -b -c;\n}\n" ); +test!( + alllows_escaped_quote_at_start_of_ident, + "a {\n color: \\\"c\\\";\n}\n" +);