allow non-ascii alphanumeric characters in selectors
This commit is contained in:
parent
b94a2403d0
commit
6b9f68922f
@ -151,13 +151,20 @@ struct StyleSheetParser<'a> {
|
|||||||
path: &'a Path,
|
path: &'a Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_selector_char(c: char) -> bool {
|
||||||
|
c.is_alphanumeric()
|
||||||
|
|| matches!(
|
||||||
|
c,
|
||||||
|
'_' | '-' | '[' | '#' | ':' | '*' | '%' | '.' | '>' | '\\'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> StyleSheetParser<'a> {
|
impl<'a> StyleSheetParser<'a> {
|
||||||
fn parse_toplevel(mut self) -> SassResult<(Vec<Spanned<Stmt>>, Scope)> {
|
fn parse_toplevel(mut self) -> SassResult<(Vec<Spanned<Stmt>>, Scope)> {
|
||||||
let mut rules: Vec<Spanned<Stmt>> = Vec::new();
|
let mut rules: Vec<Spanned<Stmt>> = Vec::new();
|
||||||
while let Some(Token { kind, .. }) = self.lexer.peek() {
|
while let Some(Token { kind, .. }) = self.lexer.peek() {
|
||||||
match kind {
|
match kind {
|
||||||
'a'..='z' | 'A'..='Z' | '_' | '-' | '0'..='9'
|
_ if is_selector_char(*kind) => rules
|
||||||
| '[' | '#' | ':' | '*' | '%' | '.' | '>' | '\\' => rules
|
|
||||||
.extend(self.eat_rules(&Selector::new(), &mut Scope::new())?),
|
.extend(self.eat_rules(&Selector::new(), &mut Scope::new())?),
|
||||||
'\t' | '\n' | ' ' => {
|
'\t' | '\n' | ' ' => {
|
||||||
self.lexer.next();
|
self.lexer.next();
|
||||||
|
@ -520,3 +520,8 @@ test!(
|
|||||||
"$a: aaaaaaaaaaa;\n\n#{$a} {\n color: foo;\n}\n",
|
"$a: aaaaaaaaaaa;\n\n#{$a} {\n color: foo;\n}\n",
|
||||||
"aaaaaaaaaaa {\n color: foo;\n}\n"
|
"aaaaaaaaaaa {\n color: foo;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
toplevel_non_ascii_alphabetic,
|
||||||
|
"ℓ {\n color: red;\n}\n",
|
||||||
|
"@charset \"UTF-8\";\nℓ {\n color: red;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user