Skip to content

Commit 493e05a

Browse files
committed
support unicode characters in scss indentifers
1 parent 3eaa3f8 commit 493e05a

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/Parser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct($sourceName, $sourceIndex = 0)
8585
$commentMultiRight = '\*\/';
8686

8787
self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight;
88-
self::$whitePattern = '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/Ais';
88+
self::$whitePattern = '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/AisuS';
8989
}
9090
}
9191

@@ -762,7 +762,7 @@ protected function peek($regex, &$out, $from = null)
762762
$from = $this->count;
763763
}
764764

765-
$r = '/' . $regex . '/Ais';
765+
$r = '/' . $regex . '/Aisu';
766766
$result = preg_match($r, $this->buffer, $out, null, $from);
767767

768768
return $result;
@@ -842,7 +842,7 @@ protected function match($regex, &$out, $eatWhitespace = null)
842842
$eatWhitespace = $this->eatWhiteDefault;
843843
}
844844

845-
$r = '/' . $regex . '/Ais';
845+
$r = '/' . $regex . '/Aisu';
846846

847847
if (preg_match($r, $this->buffer, $out, null, $this->count)) {
848848
$this->count += strlen($out[0]);
@@ -2235,7 +2235,7 @@ protected function variable(&$out)
22352235
protected function keyword(&$word, $eatWhitespace = null)
22362236
{
22372237
if ($this->match(
2238-
'(([\w_\-\*!"\']|[\\\\].)([\w\-_"\']|[\\\\].)*)',
2238+
'(([\pL\w_\-\*!"\']|[\\\\].)([\pL\w\-_"\']|[\\\\].)*)',
22392239
$m,
22402240
$eatWhitespace
22412241
)) {
@@ -2256,7 +2256,7 @@ protected function keyword(&$word, $eatWhitespace = null)
22562256
*/
22572257
protected function placeholder(&$placeholder)
22582258
{
2259-
if ($this->match('([\w\-_]+|#[{][$][\w\-_]+[}])', $m)) {
2259+
if ($this->match('([\pL\w\-_]+|#[{][$][\pL\w\-_]+[}])', $m)) {
22602260
$placeholder = $m[1];
22612261

22622262
return true;

tests/inputs/variables.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ A {
7373
@include example;
7474
color: $color;
7575
}
76+
77+
$коммент : #000;
78+
79+
body
80+
{
81+
color: $коммент ;
82+
}

tests/outputs/variables.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ body {
3131

3232
A {
3333
color: green; }
34+
35+
body {
36+
color: #000; }

tests/outputs_numbered/variables.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ body {
3434
/* line 71, inputs/variables.scss */
3535
A {
3636
color: green; }
37+
/* line 79, inputs/variables.scss */
38+
body {
39+
color: #000; }

0 commit comments

Comments
 (0)