diff --git a/src/Languages/Blade/BladeLanguage.php b/src/Languages/Blade/BladeLanguage.php index 99c5a54..b4740d2 100644 --- a/src/Languages/Blade/BladeLanguage.php +++ b/src/Languages/Blade/BladeLanguage.php @@ -9,6 +9,8 @@ use Tempest\Highlight\Languages\Blade\Injections\BladePhpInjection; use Tempest\Highlight\Languages\Blade\Injections\BladeRawEchoInjection; use Tempest\Highlight\Languages\Blade\Patterns\BladeCommentPattern; +use Tempest\Highlight\Languages\Blade\Patterns\BladeComponentCloseTagPattern; +use Tempest\Highlight\Languages\Blade\Patterns\BladeComponentOpenTagPattern; use Tempest\Highlight\Languages\Blade\Patterns\BladeKeywordPattern; use Tempest\Highlight\Languages\Html\HtmlLanguage; @@ -34,6 +36,8 @@ public function getPatterns(): array { return [ ...parent::getPatterns(), + new BladeComponentOpenTagPattern(), + new BladeComponentCloseTagPattern(), new BladeKeywordPattern(), new BladeCommentPattern(), ]; diff --git a/src/Languages/Blade/Patterns/BladeComponentCloseTagPattern.php b/src/Languages/Blade/Patterns/BladeComponentCloseTagPattern.php new file mode 100644 index 0000000..e089f1c --- /dev/null +++ b/src/Languages/Blade/Patterns/BladeComponentCloseTagPattern.php @@ -0,0 +1,29 @@ +', output: 'a')] +#[PatternTest(input: '', output: 'x-hello')] +#[PatternTest(input: '', output: 'x-hello::world')] +#[PatternTest(input: '', output: 'x-hello::world.lorem')] +final readonly class BladeComponentCloseTagPattern implements Pattern +{ + use IsPattern; + + public function getPattern(): string + { + return '<\/(?[\w\-\:\.]+)'; + } + + public function getTokenType(): TokenTypeEnum + { + return TokenTypeEnum::KEYWORD; + } +} diff --git a/src/Languages/Blade/Patterns/BladeComponentOpenTagPattern.php b/src/Languages/Blade/Patterns/BladeComponentOpenTagPattern.php new file mode 100644 index 0000000..edcd938 --- /dev/null +++ b/src/Languages/Blade/Patterns/BladeComponentOpenTagPattern.php @@ -0,0 +1,29 @@ +', output: 'a')] +#[PatternTest(input: '', output: 'x-hello')] +#[PatternTest(input: '', output: 'x-hello::world')] +#[PatternTest(input: '', output: 'x-hello::world.lorem')] +final readonly class BladeComponentOpenTagPattern implements Pattern +{ + use IsPattern; + + public function getPattern(): string + { + return '<(?[\w\-\:\.]+)'; + } + + public function getTokenType(): TokenTypeEnum + { + return TokenTypeEnum::KEYWORD; + } +} diff --git a/src/Languages/Php/Patterns/PhpCloseTagPattern.php b/src/Languages/Php/Patterns/PhpCloseTagPattern.php new file mode 100644 index 0000000..158659d --- /dev/null +++ b/src/Languages/Php/Patterns/PhpCloseTagPattern.php @@ -0,0 +1,26 @@ +', output: '?>')] +final readonly class PhpCloseTagPattern implements Pattern +{ + use IsPattern; + + public function getPattern(): string + { + return '(?\?\>+)'; + } + + public function getTokenType(): TokenTypeEnum + { + return TokenTypeEnum::KEYWORD; + } +} diff --git a/src/Languages/Php/Patterns/PhpOpenTagPattern.php b/src/Languages/Php/Patterns/PhpOpenTagPattern.php new file mode 100644 index 0000000..fef3c75 --- /dev/null +++ b/src/Languages/Php/Patterns/PhpOpenTagPattern.php @@ -0,0 +1,27 @@ +\<\?[=|php]+)'; + } + + public function getTokenType(): TokenTypeEnum + { + return TokenTypeEnum::KEYWORD; + } +} diff --git a/src/Languages/Php/PhpLanguage.php b/src/Languages/Php/PhpLanguage.php index fbf90c1..51ba03e 100644 --- a/src/Languages/Php/PhpLanguage.php +++ b/src/Languages/Php/PhpLanguage.php @@ -34,6 +34,8 @@ use Tempest\Highlight\Languages\Php\Patterns\NestedFunctionCallPattern; use Tempest\Highlight\Languages\Php\Patterns\NewObjectPattern; use Tempest\Highlight\Languages\Php\Patterns\OperatorPattern; +use Tempest\Highlight\Languages\Php\Patterns\PhpCloseTagPattern; +use Tempest\Highlight\Languages\Php\Patterns\PhpOpenTagPattern; use Tempest\Highlight\Languages\Php\Patterns\PropertyAccessPattern; use Tempest\Highlight\Languages\Php\Patterns\PropertyHookGetPattern; use Tempest\Highlight\Languages\Php\Patterns\PropertyHookSetParameterTypePattern; @@ -76,6 +78,8 @@ public function getPatterns(): array return [ ...parent::getPatterns(), + new PhpOpenTagPattern(), + new PhpCloseTagPattern(), new UseFunctionNamePattern(), new UseFunctionPattern(), new ClassNamePattern(),