diff --git a/src/format.rs b/src/format.rs index 3f843b5..88fc419 100644 --- a/src/format.rs +++ b/src/format.rs @@ -112,7 +112,7 @@ impl PrettyPrinter { } #[cfg(test)] -mod test { +mod test_scss { use super::StyleSheet; macro_rules! test { ($func:ident, $input:literal) => { @@ -145,6 +145,7 @@ mod test { test!(empty, ""); test!(basic_nesting, "a {\n b {\n }\n}\n"); + test!(mul_nesting, "a, b {\n a, b {\n }\n}\n"); test!(ident_with_num, "el1 {\n}\n"); test!(selector_element, "a {\n}\n"); diff --git a/src/lexer.rs b/src/lexer.rs index 5e7788d..c5aa2d2 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -102,7 +102,7 @@ impl<'a> Lexer<'a> { fn lex_at_rule(&mut self) -> TokenKind { let mut string = String::with_capacity(99); while let Some(c) = self.buf.peek() { - if !c.is_alphabetic() && c != &'-' { + if !c.is_alphabetic() && c != &'-' && c != &'_' { break; } let tok = self @@ -163,7 +163,7 @@ impl<'a> Lexer<'a> { fn lex_attr(&mut self) -> TokenKind { let mut attr = String::with_capacity(99); while let Some(c) = self.buf.peek() { - if !c.is_alphabetic() && c != &'-' { + if !c.is_alphabetic() && c != &'-' && c != &'_' { break; } let tok = self @@ -229,7 +229,7 @@ impl<'a> Lexer<'a> { let mut case_sensitive = true; while let Some(c) = self.buf.peek() { - if !c.is_alphabetic() && c != &'-' { + if !c.is_alphabetic() && c != &'-' && c != &'_' { break; } @@ -288,7 +288,7 @@ impl<'a> Lexer<'a> { self.pos.next_char(); let mut name = String::with_capacity(99); while let Some(c) = self.buf.peek() { - if !c.is_alphabetic() && c != &'-' { + if !c.is_alphabetic() && c != &'-' && c != &'_' { break; } let tok = self @@ -305,7 +305,7 @@ impl<'a> Lexer<'a> { let mut string = String::with_capacity(99); while let Some(c) = self.buf.peek() { // we know that the first char is alphabetic from peeking - if !c.is_alphanumeric() && c != &'-' { + if !c.is_alphanumeric() && c != &'-' && c != &'_' { break; } let tok = self