Skip to content

Commit fa980f4

Browse files
cdervclaude
andcommitted
Fix SCSSParsingError on unicode characters in SCSS selectors (#14065)
scss-parser@1.0.6 tokenizer uses ASCII-only regex for identifiers, rejecting valid non-ASCII CSS characters (e.g., #présentation). Encode non-ASCII characters as ASCII codepoint placeholders before parsing since the parser is only used for variable analysis, not CSS generation. Fixes #14065 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ee48e6 commit fa980f4

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/core/sass/analyzer/parse.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export const makeParserModule = (
4141
"$1: $2",
4242
);
4343

44+
// scss-parser's tokenizer only handles ASCII identifier characters.
45+
// Encode non-ASCII characters as ASCII codepoint placeholders since the
46+
// parser is only used for variable analysis, not CSS generation.
47+
contents = contents.replaceAll(
48+
/[^\x00-\x7F]/g,
49+
(ch) => `_u${ch.codePointAt(0)!.toString(16)}_`,
50+
);
51+
4452
// This is relatively painful, because unfortunately the error message of scss-parser
4553
// is not helpful.
4654

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*-- scss:rules --*/
2+
3+
#présentation p {
4+
line-height: 2;
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Unicode SCSS Test"
3+
format:
4+
html:
5+
theme:
6+
- default
7+
- custom-14065.scss
8+
_quarto:
9+
tests:
10+
html:
11+
ensureCssRegexMatches:
12+
- ['#présentation p', '--quarto-scss-export-']
13+
---
14+
15+
## Présentation
16+
17+
Unicode characters in headings become CSS selectors.

0 commit comments

Comments
 (0)