Skip to content

Commit 9d68c67

Browse files
committed
Allow numbers in tag names
1 parent 7012018 commit 9d68c67

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

source/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function tokens($code)
118118
continue;
119119
}
120120

121-
preg_match("#^</?[a-zA-Z.]#", substr($code, $cursor, 3), $matchesStart);
121+
preg_match("#^</?[0-9a-zA-Z.]#", substr($code, $cursor, 3), $matchesStart);
122122

123123
if (
124124
count($matchesStart)
@@ -174,7 +174,7 @@ public function tokens($code)
174174
$tokens[] = $token;
175175

176176
if (preg_match("#/>$#", $tag)) {
177-
preg_match("#<([a-zA-Z.\-_]+)#", $tag, $matchesName);
177+
preg_match("#<([0-9a-zA-Z.\-_]+)#", $tag, $matchesName);
178178

179179
$previous = $tokens[count($tokens) - 1];
180180
$tokens[count($tokens) - 1]["value"] = trim(substr($previous["value"], 0, strlen($previous["value"]) - 2)) . ">";
@@ -221,7 +221,7 @@ public function nodes($tokens)
221221
$token =& $tokens[$cursor];
222222

223223
if ($token["type"] === "tag" && $token["value"][1] !== "/") {
224-
preg_match("#^<([a-zA-Z.\-_]+)#", $token["value"], $matches);
224+
preg_match("#^<([0-9a-zA-Z.\-_]+)#", $token["value"], $matches);
225225

226226
if ($current !== null) {
227227
$token["parent"] =& $current;
@@ -241,7 +241,7 @@ public function nodes($tokens)
241241
}
242242
}
243243
} elseif ($token["type"] === "tag" && $token["value"][1] === "/") {
244-
preg_match("#^</([a-zA-Z.\-_]+)#", $token["value"], $matches);
244+
preg_match("#^</([0-9a-zA-Z.\-_]+)#", $token["value"], $matches);
245245

246246
$name = str_replace(".", "\\", $matches[1]);
247247

tests/fixtures/compile/can-compile.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function Error($props)
1414
render("span", [
1515
"className" => "icon"
1616
]),
17+
render("h4", [
18+
"children" => "Error"
19+
]),
1720
"You forgot the",
1821
$props->name,
1922
"field"

tests/fixtures/compile/can-compile.pre

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function Error($props) {
99
}}
1010
>
1111
<span className={"icon"}></span>
12+
<h4>Error</h4>
1213
You forgot the {$props->name} field
1314
</div>
1415
);

0 commit comments

Comments
 (0)