Skip to content

Commit 29c1d84

Browse files
committed
Add support for unicode-range
1 parent 1c471f9 commit 29c1d84

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ private function parsePrimitiveValue() {
454454
$oValue = $this->parseMicrosoftFilter();
455455
} else if ($this->comes("[")) {
456456
$oValue = $this->parseLineNameValue();
457+
} else if ($this->comes("U+")) {
458+
$oValue = $this->parseUnicodeRangeValue();
457459
} else {
458460
$oValue = $this->parseIdentifier(true, false);
459461
}
@@ -505,6 +507,14 @@ private function parseLineNameValue() {
505507
return new LineName($aNames, $this->iLineNo);
506508
}
507509

510+
private function parseUnicodeRangeValue() {
511+
$sRange = "";
512+
do {
513+
$sRange .= $this->consume(1);
514+
} while (!$this->comes(',') && !$this->comes(';') && !$this->comes('}'));
515+
return $sRange;
516+
}
517+
508518
private function parseColorValue() {
509519
$aColor = array();
510520
if ($this->comes('#')) {

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ function testUnicodeParsing() {
126126
}
127127
}
128128

129+
function testUnicodeRangeParsing() {
130+
$oDoc = $this->parsedStructureForFile('unicode-range');
131+
$sExpected = "@font-face {unicode-range: U+0100-024F,U+0259,U+1E??-2EFF,U+202F;}";
132+
$this->assertSame($sExpected, $oDoc->render());
133+
}
134+
129135
function testSpecificity() {
130136
$oDoc = $this->parsedStructureForFile('specificity');
131137
$oDeclarationBlock = $oDoc->getAllDeclarationBlocks();

tests/files/unicode-range.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@font-face {
2+
unicode-range: U+0100-024F, U+0259, U+1E??-2EFF, U+202F;
3+
}

0 commit comments

Comments
 (0)