diff --git a/src/TagEngine.php b/src/TagEngine.php
index 8f649d3..826c950 100644
--- a/src/TagEngine.php
+++ b/src/TagEngine.php
@@ -202,13 +202,13 @@ protected function replaceComponent(array $matches): string
protected function parseAttributes(string $attributesString): array
{
// Regex to match attributes (both static and dynamic)
- $pattern = '/([:\w-]+)(?:=["\']([^"\']+)["\'])?/';
- preg_match_all($pattern, $attributesString, $matches, PREG_SET_ORDER);
+ $pattern = '/([:\w-]+)(?:\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^\s"\'=<>`]+)))?/';
+ preg_match_all($pattern, $attributesString, $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL);
$attributes = [];
foreach ($matches as $match) {
$name = $match[1];
- $value = $match[2] ?? true; // If no value, set it to true
+ $value = $match[2] ?? $match[3] ?? $match[4] ?? true; // If no value, set it to true
$name = str_replace('-', '_', $name); // Replace hyphens with underscores so that it works with properties
diff --git a/tests/TagEngine/CustomTagsTest.php b/tests/TagEngine/CustomTagsTest.php
index ed3977b..d5db9c7 100644
--- a/tests/TagEngine/CustomTagsTest.php
+++ b/tests/TagEngine/CustomTagsTest.php
@@ -43,6 +43,20 @@ public function testTagWithAttribute(): void
$this->assertSame($expected, $result);
}
+ public function testTagWithUnquotedAttribute(): void
+ {
+ $result = $this->tagEngine->parse('