Skip to content

Commit 9966dbe

Browse files
committed
Reimplement the unicode-range support after the parser logic refactor
1 parent 1c6572f commit 9966dbe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sabberworm/CSS/Value/Value.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public static function parsePrimitiveValue(ParserState $oParserState) {
8888
$oValue = self::parseMicrosoftFilter($oParserState);
8989
} else if ($oParserState->comes("[")) {
9090
$oValue = LineName::parse($oParserState);
91+
} else if ($oParserState->comes("U+")) {
92+
$oValue = self::parseUnicodeRangeValue($oParserState);
9193
} else {
9294
$oValue = self::parseIdentifierOrFunction($oParserState);
9395
}
@@ -100,6 +102,17 @@ private static function parseMicrosoftFilter(ParserState $oParserState) {
100102
$aArguments = Value::parseValue($oParserState, array(',', '='));
101103
return new CSSFunction($sFunction, $aArguments, ',', $oParserState->currentLine());
102104
}
105+
106+
private static function parseUnicodeRangeValue(ParserState $oParserState) {
107+
$iCodepointMaxLenth = 6; // Code points outside BMP can use up to six digits
108+
$sRange = "";
109+
$oParserState->consume("U+");
110+
do {
111+
if ($oParserState->comes('-')) $iCodepointMaxLenth = 13; // Max length is 2 six digit code points + the dash(-) between them
112+
$sRange .= $oParserState->consume(1);
113+
} while (strlen($sRange) < $iCodepointMaxLenth && preg_match("/[A-Fa-f0-9\?-]/", $oParserState->peek()));
114+
return "U+{$sRange}";
115+
}
103116

104117
/**
105118
* @return int

0 commit comments

Comments
 (0)