diff --git a/src/Languages/Base/Injections/DeletionInjection.php b/src/Languages/Base/Injections/DeletionInjection.php index 355a49f..8fef3b2 100644 --- a/src/Languages/Base/Injections/DeletionInjection.php +++ b/src/Languages/Base/Injections/DeletionInjection.php @@ -18,7 +18,7 @@ public function parse(string $content, Highlighter $highlighter): ParsedInjectio $content = str_replace('❷span class=❹ignore❹❸{-❷/span❸', '{-', $content); $content = str_replace('❷span class=❹ignore❹❸-}❷/span❸', '-}', $content); - preg_match_all('/(\{-)((.|\n)*?)(-})/', $content, $matches, PREG_OFFSET_CAPTURE); + preg_match_all('/(\{-)(?!-)((.|\n)*?)(-})/', $content, $matches, PREG_OFFSET_CAPTURE); $parsedOffset = 0; diff --git a/src/Languages/Base/Patterns/DeletionEndTokenPattern.php b/src/Languages/Base/Patterns/DeletionEndTokenPattern.php index eba69c8..f40d9a9 100644 --- a/src/Languages/Base/Patterns/DeletionEndTokenPattern.php +++ b/src/Languages/Base/Patterns/DeletionEndTokenPattern.php @@ -11,13 +11,14 @@ use Tempest\Highlight\Tokens\TokenType; #[PatternTest('{- pull_request_target: -}', '-}')] +#[PatternTest('{-- pull_request_target: --}', null)] final readonly class DeletionEndTokenPattern implements Pattern { use IsPattern; public function getPattern(): string { - return '/(?\-})/'; + return '/(?\-})/'; } public function getTokenType(): TokenType diff --git a/src/Languages/Base/Patterns/DeletionStartTokenPattern.php b/src/Languages/Base/Patterns/DeletionStartTokenPattern.php index bc7acfa..7a7977d 100644 --- a/src/Languages/Base/Patterns/DeletionStartTokenPattern.php +++ b/src/Languages/Base/Patterns/DeletionStartTokenPattern.php @@ -11,13 +11,14 @@ use Tempest\Highlight\Tokens\TokenType; #[PatternTest('{- pull_request_target: -}', '{-')] +#[PatternTest('{-- pull_request_target: --}', null)] final readonly class DeletionStartTokenPattern implements Pattern { use IsPattern; public function getPattern(): string { - return '/(?{\-)/'; + return '/(?{\-)(?!-)/'; } public function getTokenType(): TokenType diff --git a/tests/Languages/Blade/BladeLanguageTest.php b/tests/Languages/Blade/BladeLanguageTest.php new file mode 100644 index 0000000..500999e --- /dev/null +++ b/tests/Languages/Blade/BladeLanguageTest.php @@ -0,0 +1,30 @@ +assertSame( + $expected, + $highlighter->parse($content, 'blade'), + ); + } + + public static function data(): array + { + return [ + ['{{-- Blade comment --}}', '{{-- Blade comment --}}'], + ]; + } +} diff --git a/tests/targets/test.md b/tests/targets/test.md index 315fc5f..a631870 100644 --- a/tests/targets/test.md +++ b/tests/targets/test.md @@ -1,3 +1,3 @@ -```php -self::$staticProperty; +```blade +{{-- Blade comment --}} ``` \ No newline at end of file