-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from tonysm/main
PHP Tags and Blade Namespaced Components
- Loading branch information
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Languages/Blade/Patterns/BladeComponentCloseTagPattern.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tempest\Highlight\Languages\Blade\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\PatternTest; | ||
use Tempest\Highlight\Tokens\TokenTypeEnum; | ||
|
||
#[PatternTest(input: '</a>', output: 'a')] | ||
#[PatternTest(input: '</x-hello>', output: 'x-hello')] | ||
#[PatternTest(input: '</x-hello::world>', output: 'x-hello::world')] | ||
#[PatternTest(input: '</x-hello::world.lorem>', output: 'x-hello::world.lorem')] | ||
final readonly class BladeComponentCloseTagPattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '<\/(?<match>[\w\-\:\.]+)'; | ||
} | ||
|
||
public function getTokenType(): TokenTypeEnum | ||
{ | ||
return TokenTypeEnum::KEYWORD; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Languages/Blade/Patterns/BladeComponentOpenTagPattern.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tempest\Highlight\Languages\Blade\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\PatternTest; | ||
use Tempest\Highlight\Tokens\TokenTypeEnum; | ||
|
||
#[PatternTest(input: '<a attr="">', output: 'a')] | ||
#[PatternTest(input: '<x-hello attr="">', output: 'x-hello')] | ||
#[PatternTest(input: '<x-hello::world attr="">', output: 'x-hello::world')] | ||
#[PatternTest(input: '<x-hello::world.lorem attr="">', output: 'x-hello::world.lorem')] | ||
final readonly class BladeComponentOpenTagPattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '<(?<match>[\w\-\:\.]+)'; | ||
} | ||
|
||
public function getTokenType(): TokenTypeEnum | ||
{ | ||
return TokenTypeEnum::KEYWORD; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tempest\Highlight\Languages\Php\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\PatternTest; | ||
use Tempest\Highlight\Tokens\TokenTypeEnum; | ||
|
||
#[PatternTest(input: '?>', output: '?>')] | ||
final readonly class PhpCloseTagPattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '(?<match>\?\>+)'; | ||
} | ||
|
||
public function getTokenType(): TokenTypeEnum | ||
{ | ||
return TokenTypeEnum::KEYWORD; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tempest\Highlight\Languages\Php\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\PatternTest; | ||
use Tempest\Highlight\Tokens\TokenTypeEnum; | ||
|
||
#[PatternTest(input: '<?php', output: '<?php')] | ||
#[PatternTest(input: '<?=', output: '<?=')] | ||
final readonly class PhpOpenTagPattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '(?<match>\<\?[=|php]+)'; | ||
} | ||
|
||
public function getTokenType(): TokenTypeEnum | ||
{ | ||
return TokenTypeEnum::KEYWORD; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters