.*)/', $node->getLiteral(), $match);
28 |
29 | $language = $match['match'] ?? 'txt';
30 | $code = $match['code'] ?? $node->getLiteral();
31 |
32 | return '' . $this->highlighter->parse($code, $language) . '
';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Injection.php:
--------------------------------------------------------------------------------
1 | getPattern();
16 |
17 | if (! str_starts_with($pattern, '/')) {
18 | $pattern = "/{$pattern}/";
19 | }
20 |
21 | $result = preg_replace_callback(
22 | pattern: $pattern,
23 | callback: function ($matches) use ($highlighter) {
24 | $content = $matches['match'] ?? '';
25 |
26 | if (! $content) {
27 | return $matches[0];
28 | }
29 |
30 | return str_replace(
31 | search: $content,
32 | replace: $this->parseContent($content, $highlighter),
33 | subject: $matches[0],
34 | );
35 | },
36 | subject: $content,
37 | );
38 |
39 | return new ParsedInjection($result ?? $content);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/IsPattern.php:
--------------------------------------------------------------------------------
1 | getPattern();
14 |
15 | if (! str_starts_with($pattern, '/')) {
16 | $pattern = "/$pattern/";
17 | }
18 |
19 | preg_match_all($pattern, $content, $matches, PREG_OFFSET_CAPTURE);
20 |
21 | return $matches;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Language.php:
--------------------------------------------------------------------------------
1 | \+})/';
21 | }
22 |
23 | public function getTokenType(): TokenType
24 | {
25 | return new IgnoreTokenType();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Base/Patterns/AdditionStartTokenPattern.php:
--------------------------------------------------------------------------------
1 | {\+)/';
21 | }
22 |
23 | public function getTokenType(): TokenType
24 | {
25 | return new IgnoreTokenType();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Base/Patterns/DeletionEndTokenPattern.php:
--------------------------------------------------------------------------------
1 | \-})/';
22 | }
23 |
24 | public function getTokenType(): TokenType
25 | {
26 | return new IgnoreTokenType();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Base/Patterns/DeletionStartTokenPattern.php:
--------------------------------------------------------------------------------
1 | {\-)(?!-)/';
22 | }
23 |
24 | public function getTokenType(): TokenType
25 | {
26 | return new IgnoreTokenType();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Base/Patterns/InjectionTokenPattern.php:
--------------------------------------------------------------------------------
1 | (.|\n)*?)' . Escape::INJECTION_TOKEN;
19 | }
20 |
21 | public function getTokenType(): TokenTypeEnum
22 | {
23 | return TokenTypeEnum::INJECTION;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Injections/BladeEchoInjection.php:
--------------------------------------------------------------------------------
1 | .*)(}})';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Injections/BladeKeywordInjection.php:
--------------------------------------------------------------------------------
1 | .*)\)';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Injections/BladePhpInjection.php:
--------------------------------------------------------------------------------
1 | (.|\n)*?)\@endphp';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Injections/BladeRawEchoInjection.php:
--------------------------------------------------------------------------------
1 | .*)(!!})';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Patterns/BladeCommentPattern.php:
--------------------------------------------------------------------------------
1 | \{\{\-\-(.|\n)*?\-\-\}\})';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::COMMENT;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Patterns/BladeComponentCloseTagPattern.php:
--------------------------------------------------------------------------------
1 | ', output: 'a')]
13 | #[PatternTest(input: '', output: 'x-hello')]
14 | #[PatternTest(input: '', output: 'x-hello::world')]
15 | #[PatternTest(input: '', output: 'x-hello::world.lorem')]
16 | final readonly class BladeComponentCloseTagPattern implements Pattern
17 | {
18 | use IsPattern;
19 |
20 | public function getPattern(): string
21 | {
22 | return '<\/(?[\w\-\:\.]+)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::KEYWORD;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Patterns/BladeComponentOpenTagPattern.php:
--------------------------------------------------------------------------------
1 | ', output: 'a')]
13 | #[PatternTest(input: '', output: 'x-hello')]
14 | #[PatternTest(input: '', output: 'x-hello::world')]
15 | #[PatternTest(input: '', output: 'x-hello::world.lorem')]
16 | final readonly class BladeComponentOpenTagPattern implements Pattern
17 | {
18 | use IsPattern;
19 |
20 | public function getPattern(): string
21 | {
22 | return '<(?[\w\-\:\.]+)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::KEYWORD;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Blade/Patterns/BladeKeywordPattern.php:
--------------------------------------------------------------------------------
1 | \@[\w]+)\b';
24 | }
25 |
26 | public function getTokenType(): TokenTypeEnum
27 | {
28 | return TokenTypeEnum::KEYWORD;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssAttributePattern.php:
--------------------------------------------------------------------------------
1 | [\w\-]+):';
27 | }
28 |
29 | public function getTokenType(): TokenTypeEnum
30 | {
31 | return TokenTypeEnum::PROPERTY;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssCommentPattern.php:
--------------------------------------------------------------------------------
1 | \/\*(.|\n)*?\*\/)/m';
26 | }
27 |
28 | public function getTokenType(): TokenTypeEnum
29 | {
30 | return TokenTypeEnum::COMMENT;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssFunctionPattern.php:
--------------------------------------------------------------------------------
1 | [\w\-]+)\(';
28 | }
29 |
30 | public function getTokenType(): TokenTypeEnum
31 | {
32 | return TokenTypeEnum::KEYWORD;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssImportPattern.php:
--------------------------------------------------------------------------------
1 | \@import)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::KEYWORD;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssMediaQueryPattern.php:
--------------------------------------------------------------------------------
1 | \@media(.*)?){';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::KEYWORD;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssSelectorPattern.php:
--------------------------------------------------------------------------------
1 | [\[\]\'\"\=\@\-\#\.\w\s,\n\+\:\(\)\*]+)\{';
35 | }
36 |
37 | public function getTokenType(): TokenTypeEnum
38 | {
39 | return TokenTypeEnum::KEYWORD;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Languages/Css/Patterns/CssVariablePattern.php:
--------------------------------------------------------------------------------
1 | \-\-[\w\-]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Diff/DiffLanguage.php:
--------------------------------------------------------------------------------
1 | + ');
19 | $close = Escape::tokens('');
20 |
21 | return $open . $matches[1] . $close;
22 | },
23 | $content
24 | );
25 |
26 | return new ParsedInjection($content);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Diff/Injections/DiffDeletionInjection.php:
--------------------------------------------------------------------------------
1 | - ');
19 | $close = Escape::tokens('');
20 |
21 | return $open . $matches[1] . $close; // Wraps the matched line with the span
22 | },
23 | $content
24 | );
25 |
26 | return new ParsedInjection($content);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/DocComment/DocCommentLanguage.php:
--------------------------------------------------------------------------------
1 | \@[\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::VALUE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Dockerfile/Patterns/ImageAliasKeywordPattern.php:
--------------------------------------------------------------------------------
1 | AS)[\s][\S]+/m";
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::KEYWORD;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Dockerfile/Patterns/ImageAliasNamePattern.php:
--------------------------------------------------------------------------------
1 | [\S]+)/m";
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Dockerfile/Patterns/ImageNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w\/]+)/m";
25 | }
26 |
27 | public function getTokenType(): TokenTypeEnum
28 | {
29 | return TokenTypeEnum::VALUE;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Languages/Dockerfile/Patterns/ImageTagPattern.php:
--------------------------------------------------------------------------------
1 | \S+)[\s]?/m";
25 | }
26 |
27 | public function getTokenType(): TokenTypeEnum
28 | {
29 | return TokenTypeEnum::VALUE;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Languages/Dockerfile/Patterns/KeywordPattern.php:
--------------------------------------------------------------------------------
1 | {$this->keyword})[\s].*/m";
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::KEYWORD;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Ellison/EllisonLanguage.php:
--------------------------------------------------------------------------------
1 | [a-zA-Z][a-zA-Z0-9]+)\b';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/ClassNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/DoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)"';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/ExtendsPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/FunctionCallPattern.php:
--------------------------------------------------------------------------------
1 | [a-z][\w]+)\(';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/FunctionNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/KeywordPattern.php:
--------------------------------------------------------------------------------
1 | {$this->keyword})\b/";
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::KEYWORD;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/OperatorPattern.php:
--------------------------------------------------------------------------------
1 | operator, '/');
22 |
23 | return "/(?{$quoted})/";
24 | }
25 |
26 | public function getTokenType(): TokenTypeEnum
27 | {
28 | return TokenTypeEnum::OPERATOR;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/PropertyAccessPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/ReturnTypePattern.php:
--------------------------------------------------------------------------------
1 | Bar:', output: 'Bar')]
13 | #[PatternTest(input: 'func foo() -> Bar :', output: 'Bar')]
14 | final readonly class ReturnTypePattern implements Pattern
15 | {
16 | use IsPattern;
17 |
18 | public function getPattern(): string
19 | {
20 | return '\)\s*\-\>\s*(?.+?)[\s*:\n]';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/SingleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)'";
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/SinglelineCommentPattern.php:
--------------------------------------------------------------------------------
1 | #(.)*)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::COMMENT;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Gdscript/Patterns/VarTypePattern.php:
--------------------------------------------------------------------------------
1 | \w+)';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::TYPE;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Html/HtmlLanguage.php:
--------------------------------------------------------------------------------
1 | (.|\n)*?)"';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'css');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Html/Injections/CssInHtmlInjection.php:
--------------------------------------------------------------------------------
1 | (?(.|\n)*?)<\/style>';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'css');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Html/Injections/JavaScriptInHtmlInjection.php:
--------------------------------------------------------------------------------
1 | (?(.|\n)*)<\/script>';
19 | }
20 |
21 | public function parseContent(string $content, Highlighter $highlighter): string
22 | {
23 | return $highlighter->parse($content, new JavaScriptLanguage());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Languages/Html/Injections/PhpInHtmlInjection.php:
--------------------------------------------------------------------------------
1 | (.|\n)*?)\?>';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Html/Injections/PhpShortEchoInHtmlInjection.php:
--------------------------------------------------------------------------------
1 | .*)\s\?>/';
18 | }
19 |
20 | public function parseContent(string $content, Highlighter $highlighter): string
21 | {
22 | return $highlighter->parse($content, 'php');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Injections/JsDocInjection.php:
--------------------------------------------------------------------------------
1 | \/\*\*(.|\n)*?\*\/)/m';
19 | }
20 |
21 | public function parseContent(string $content, Highlighter $highlighter): string
22 | {
23 | return $highlighter->parse($content, new JsDocLanguage());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/JsDocLanguage.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsDocParamNamePattern.php:
--------------------------------------------------------------------------------
1 | (.*?))(\s|$)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsDocTypePattern.php:
--------------------------------------------------------------------------------
1 | \{(.*?)\})';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsDoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | "(\\\"|.)*?")';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsKeywordPattern.php:
--------------------------------------------------------------------------------
1 | caseInsensitive = true;
24 |
25 | return $this;
26 | }
27 |
28 | public function getPattern(): string
29 | {
30 | $pattern = "/\b(?{$this->keyword})(\,|\.|\)|\;|\:|\s|\()/";
31 |
32 | if ($this->caseInsensitive) {
33 | $pattern .= 'i';
34 | }
35 |
36 | return $pattern;
37 | }
38 |
39 | public function getTokenType(): TokenTypeEnum
40 | {
41 | return TokenTypeEnum::KEYWORD;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsMethodPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\(';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsMultilineCommentPattern.php:
--------------------------------------------------------------------------------
1 | \/\*(.|\n)*?\*\/)/m';
27 | }
28 |
29 | public function getTokenType(): TokenTypeEnum
30 | {
31 | return TokenTypeEnum::COMMENT;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsNewObjectPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)(\s)*\(';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsObjectPropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\:';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::PROPERTY;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsPropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsSingleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | '(\\\'|.)*?')";
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsSinglelineCommentPattern.php:
--------------------------------------------------------------------------------
1 | \/\/(.)*)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::COMMENT;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsStaticClassPattern.php:
--------------------------------------------------------------------------------
1 | [A-Z][\w]+)\.';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/JavaScript/Patterns/JsStaticPropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Json/JsonLanguage.php:
--------------------------------------------------------------------------------
1 | (\{|\}))';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Json/Patterns/JsonArrayBracketsPattern.php:
--------------------------------------------------------------------------------
1 | (\[|\]))';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Json/Patterns/JsonDoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | \".*?\")';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::VALUE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Json/Patterns/JsonPropertyPattern.php:
--------------------------------------------------------------------------------
1 | \"[\w\\\-]+\")(\s)*\:';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::KEYWORD;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Injections/PhpAttributeInstanceInjection.php:
--------------------------------------------------------------------------------
1 | \#\[[\w]+\((.|\n)*?\)\])';
20 | }
21 |
22 | public function parseContent(string $content, Highlighter $highlighter): string
23 | {
24 | $theme = $highlighter->getTheme();
25 |
26 | $parsed = '#[' . $highlighter->parse(str_replace(['#[', ')]'], '', $content), 'php') . ')]';
27 |
28 | return Escape::injection(
29 | Escape::tokens($theme->before(TokenTypeEnum::ATTRIBUTE))
30 | . $parsed
31 | . Escape::tokens($theme->after(TokenTypeEnum::ATTRIBUTE))
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Languages/Php/Injections/PhpAttributePlainInjection.php:
--------------------------------------------------------------------------------
1 | \#\[[\w]+\])';
20 | }
21 |
22 | public function parseContent(string $content, Highlighter $highlighter): string
23 | {
24 | $theme = $highlighter->getTheme();
25 |
26 | $parsed = '#[' . $highlighter->parse(str_replace(['#[', ']'], '', $content), 'php') . ']';
27 |
28 | return Escape::tokens($theme->before(TokenTypeEnum::ATTRIBUTE))
29 | . $parsed
30 | . Escape::tokens($theme->after(TokenTypeEnum::ATTRIBUTE));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Languages/Php/Injections/PhpDocCommentInjection.php:
--------------------------------------------------------------------------------
1 | \/\*\*(.|\n)*?\*\/)/m';
19 | }
20 |
21 | public function parseContent(string $content, Highlighter $highlighter): string
22 | {
23 | return $highlighter->parse($content, new PhpDocCommentLanguage());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Languages/Php/Injections/PhpFunctionParametersInjection.php:
--------------------------------------------------------------------------------
1 | (.|\n)*?)({|\)[\s]*({|;|:|=>))';
20 | }
21 |
22 | public function parseContent(string $content, Highlighter $highlighter): string
23 | {
24 | return Escape::injection(
25 | $highlighter->parse($content, new PhpTypeLanguage())
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/AttributeTypePattern.php:
--------------------------------------------------------------------------------
1 | [\\\\]*[A-Z][\w\\\\]+)/m';
31 | }
32 |
33 | public function getTokenType(): TokenTypeEnum
34 | {
35 | return TokenTypeEnum::TYPE;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/CatchTypePattern.php:
--------------------------------------------------------------------------------
1 | [\w\||]+)\)';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::TYPE;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ClassNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::TYPE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ClassPropertyPattern.php:
--------------------------------------------------------------------------------
1 | \\$[\w]+)';
28 | }
29 |
30 | public function getTokenType(): TokenTypeEnum
31 | {
32 | return TokenTypeEnum::PROPERTY;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ClassResolutionPattern.php:
--------------------------------------------------------------------------------
1 | class)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::KEYWORD;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ConstantNamePattern.php:
--------------------------------------------------------------------------------
1 | [A-Z_]+)\b';
31 | }
32 |
33 | public function getTokenType(): TokenTypeEnum
34 | {
35 | return TokenTypeEnum::PROPERTY;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ConstantPropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ConstantTypesPattern.php:
--------------------------------------------------------------------------------
1 | .+?)\s[\w]+\s=';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::TYPE;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/DoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | "(\\\"|.)*?")';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/EnumBackedTypePattern.php:
--------------------------------------------------------------------------------
1 | int|string)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/EnumCasePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)(\s)*(=|;)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::PROPERTY;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ExtendsPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/FunctionCallPattern.php:
--------------------------------------------------------------------------------
1 | [a-z][\w]+)\(';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/FunctionNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/GenericPattern.php:
--------------------------------------------------------------------------------
1 | pattern;
24 | }
25 |
26 | public function getTokenType(): TokenTypeEnum
27 | {
28 | return $this->tokenType;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/GroupedTypePattern.php:
--------------------------------------------------------------------------------
1 | \(\w+(&\w+)+\))';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::TYPE;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ImplementsPattern.php:
--------------------------------------------------------------------------------
1 | [\s\,\w]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/InstanceOfPattern.php:
--------------------------------------------------------------------------------
1 | [\w\\\\]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/KeywordPattern.php:
--------------------------------------------------------------------------------
1 | caseInsensitive = true;
24 |
25 | return $this;
26 | }
27 |
28 | public function getPattern(): string
29 | {
30 | $pattern = "/\b(?)(?{$this->keyword})(\$|\,|\)|\;|\:|\s|\()/";
31 |
32 | if ($this->caseInsensitive) {
33 | $pattern .= 'i';
34 | }
35 |
36 | return $pattern;
37 | }
38 |
39 | public function getTokenType(): TokenTypeEnum
40 | {
41 | return TokenTypeEnum::KEYWORD;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/MultilineSingleDocCommentPattern.php:
--------------------------------------------------------------------------------
1 | \/\*(.|\n)*?\*\/)/m';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::COMMENT;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/NamedArgumentPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+):\s';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/NamespacePattern.php:
--------------------------------------------------------------------------------
1 | [\w\\\\]+)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::TYPE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/NestedFunctionCallPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\(';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/NewObjectPattern.php:
--------------------------------------------------------------------------------
1 | [\w\\\\]+)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::TYPE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/OperatorPattern.php:
--------------------------------------------------------------------------------
1 | {$this->operator})(\s|\()/";
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::OPERATOR;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpAsymmetricPropertyPattern.php:
--------------------------------------------------------------------------------
1 | getPattern();
23 |
24 | if (! str_starts_with($pattern, '/')) {
25 | $pattern = "/$pattern/";
26 | }
27 |
28 | preg_match_all($pattern, $content, $matches, PREG_OFFSET_CAPTURE);
29 |
30 | return $matches;
31 | }
32 |
33 | public function getPattern(): string
34 | {
35 | return '/(public|private|protected)\((?set)\)/';
36 | }
37 |
38 | public function getTokenType(): TokenType
39 | {
40 | return TokenTypeEnum::KEYWORD;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpCloseTagPattern.php:
--------------------------------------------------------------------------------
1 | ', output: '?>')]
13 | final readonly class PhpCloseTagPattern implements Pattern
14 | {
15 | use IsPattern;
16 |
17 | public function getPattern(): string
18 | {
19 | return '(?\?\>+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::KEYWORD;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentGenericTypePattern.php:
--------------------------------------------------------------------------------
1 | $className', output: 'T')]
13 | final readonly class PhpDocCommentGenericTypePattern implements Pattern
14 | {
15 | use IsPattern;
16 |
17 | public function getPattern(): string
18 | {
19 | return '\<(?[\w]+)\>';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::GENERIC;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentParamTypePattern.php:
--------------------------------------------------------------------------------
1 | .*?) \\$';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentReturnTypePattern.php:
--------------------------------------------------------------------------------
1 | .*?)(\*\/|$|\R)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentReturnTypeSingleLinePattern.php:
--------------------------------------------------------------------------------
1 | .*?)(\s*\*\/|$)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentTemplateTypePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::GENERIC;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentVarTypePattern.php:
--------------------------------------------------------------------------------
1 | .*?)( \$|\*|$)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::TYPE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpDocCommentVariablePattern.php:
--------------------------------------------------------------------------------
1 | \\$[\w]+)';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VARIABLE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PhpOpenTagPattern.php:
--------------------------------------------------------------------------------
1 | \<\?[=|php]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::KEYWORD;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PropertyAccessPattern.php:
--------------------------------------------------------------------------------
1 | (?[\w]+)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::PROPERTY;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PropertyHookGetPattern.php:
--------------------------------------------------------------------------------
1 | ',
21 | 'get'
22 | )]
23 | #[PatternTest('get;', 'get')]
24 | final readonly class PropertyHookGetPattern implements Pattern
25 | {
26 | use IsPattern;
27 |
28 | public function getPattern(): string
29 | {
30 | return '(?get)\s*({|=>|;)';
31 | }
32 |
33 | public function getTokenType(): TokenType
34 | {
35 | return TokenTypeEnum::KEYWORD;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PropertyHookSetParameterTypePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
23 | }
24 |
25 | public function getTokenType(): TokenType
26 | {
27 | return TokenTypeEnum::TYPE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/PropertyHookSetPattern.php:
--------------------------------------------------------------------------------
1 | ', 'set')]
20 | #[PatternTest('set (string $value', 'set')]
21 | #[PatternTest('set(string $value', 'set')]
22 | final readonly class PropertyHookSetPattern implements Pattern
23 | {
24 | use IsPattern;
25 |
26 | public function getPattern(): string
27 | {
28 | return '(?set)\s*({|;|=>|\()';
29 | }
30 |
31 | public function getTokenType(): TokenType
32 | {
33 | return TokenTypeEnum::KEYWORD;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ReturnTypePattern.php:
--------------------------------------------------------------------------------
1 | [\w\(\)\&\|\?]+)[\s{;\n]';
28 | }
29 |
30 | public function getTokenType(): TokenTypeEnum
31 | {
32 | return TokenTypeEnum::TYPE;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/ShortFunctionReferencePattern.php:
--------------------------------------------------------------------------------
1 | ', output: 'fn')]
13 | final class ShortFunctionReferencePattern implements Pattern
14 | {
15 | use IsPattern;
16 |
17 | public function getPattern(): string
18 | {
19 | return "(?fn)\&";
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::KEYWORD;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/SingleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | '(\\\'|.)*?')";
31 | }
32 |
33 | public function getTokenType(): TokenTypeEnum
34 | {
35 | return TokenTypeEnum::VALUE;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/SinglelineCommentPattern.php:
--------------------------------------------------------------------------------
1 | (?:\/\/|#[^\[])(.)*)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::COMMENT;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/StaticClassCallPattern.php:
--------------------------------------------------------------------------------
1 | [\\\\\w]+)\:\:';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::TYPE;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/StaticPropertyPattern.php:
--------------------------------------------------------------------------------
1 | \\$[\w]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/TypeForVariablePattern.php:
--------------------------------------------------------------------------------
1 | [\w\&\(\)\|\\\\\?]+)\s+(\.*)\\$';
26 | }
27 |
28 | public function getTokenType(): TokenTypeEnum
29 | {
30 | return TokenTypeEnum::TYPE;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/UntypedClassPropertyPattern.php:
--------------------------------------------------------------------------------
1 | \\$[\w]+)';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::PROPERTY;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/UseAsPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/UseFunctionNamePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+);';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/UseFunctionPattern.php:
--------------------------------------------------------------------------------
1 | [\w\\\\]+\\\\)[\w]+\;';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/UsePattern.php:
--------------------------------------------------------------------------------
1 | [\w\\\\]+)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::TYPE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Php/Patterns/VariablePattern.php:
--------------------------------------------------------------------------------
1 | \\$[\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::VARIABLE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyArgumentPattern.php:
--------------------------------------------------------------------------------
1 | \w+)s*=';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::VARIABLE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyClassNamePattern.php:
--------------------------------------------------------------------------------
1 | \w*)(?=[\s*\:(])';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyCommentPattern.php:
--------------------------------------------------------------------------------
1 | #.*)';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::COMMENT;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyDecoratorPattern.php:
--------------------------------------------------------------------------------
1 | @\s*\w*(?:\.\w+)*)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyFunctionPattern.php:
--------------------------------------------------------------------------------
1 | \w*)(?=\s*\()';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyKeywordPattern.php:
--------------------------------------------------------------------------------
1 | keywords);
27 |
28 | return "\b(?(?:_(?=\s*:){$keywords}))\b";
29 | }
30 |
31 | public function getTokenType(): TokenTypeEnum
32 | {
33 | return TokenTypeEnum::KEYWORD;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyLogicalValuePattern.php:
--------------------------------------------------------------------------------
1 | (?:False|None|True))\b';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::LITERAL;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyNumberPattern.php:
--------------------------------------------------------------------------------
1 | \b0(?:[bB](?:_?[01])+|[oO](?:_?[0-7])+|[xX](?:_?[a-fA-F0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:[eE][+-]?\d+(?:_\d+)*)?j?(?!\w))';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::NUMBER;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyOperatorPattern.php:
--------------------------------------------------------------------------------
1 | ([-+&%=]=?|!=|:=|>>=|<<=|\|=|\^=|\*\*?=?|\/\/?=?|<[<=]?|>[=>]?|[\|^~]))";
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::OPERATOR;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyTripleDoubleQuoteStringPattern.php:
--------------------------------------------------------------------------------
1 | """(.|\n)*?""")/m';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::VALUE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Python/Patterns/PyTripleSingleQuoteStringPattern.php:
--------------------------------------------------------------------------------
1 | \'\'\'(.|\n)*?\'\'\')/m';
18 | }
19 |
20 | public function getTokenType(): TokenTypeEnum
21 | {
22 | return TokenTypeEnum::VALUE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlAsTablePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)/i';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlDoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)\"';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::VALUE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlFromTablePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)/i';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlFunctionPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\(/i';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlJoinTablePattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)/i';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::TYPE;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlMultilineCommentPattern.php:
--------------------------------------------------------------------------------
1 | \/\*(.|\n)*?\*\/)/m';
27 | }
28 |
29 | public function getTokenType(): TokenTypeEnum
30 | {
31 | return TokenTypeEnum::COMMENT;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlPropertyPattern.php:
--------------------------------------------------------------------------------
1 | (\w)+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlSingleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)\'';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::VALUE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlSinglelineCommentPattern.php:
--------------------------------------------------------------------------------
1 | \-\-(.)*)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::COMMENT;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlTableAccessPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\.';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::TYPE;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Sql/Patterns/SqlTablePropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Text/TextLanguage.php:
--------------------------------------------------------------------------------
1 | ({{(.|\n)*?}}))';
20 | }
21 |
22 | public function parseContent(string $content, Highlighter $highlighter): string
23 | {
24 | return Escape::injection($highlighter->parse($content, new TwigEchoLanguage()));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Injections/TwigTagInjection.php:
--------------------------------------------------------------------------------
1 | ({%(.|\n)*?%}))';
20 | }
21 |
22 | public function parseContent(string $content, Highlighter $highlighter): string
23 | {
24 | return Escape::injection($highlighter->parse($content, new TwigTagLanguage()));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigArrayKeyPattern.php:
--------------------------------------------------------------------------------
1 | [\w\-\'\"]+)\:';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::PROPERTY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigCommentPattern.php:
--------------------------------------------------------------------------------
1 | {# foo #}', output: '{# foo #}')]
21 | final readonly class TwigCommentPattern implements Pattern
22 | {
23 | use IsPattern;
24 |
25 | public function getPattern(): string
26 | {
27 | return '(?\{#(.|\n)*?#})';
28 | }
29 |
30 | public function getTokenType(): TokenTypeEnum
31 | {
32 | return TokenTypeEnum::COMMENT;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigDoubleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)"';
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigFilterPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigKeywordPattern.php:
--------------------------------------------------------------------------------
1 | {$this->keyword})\b";
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::KEYWORD;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigMethodPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\(';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigNamedArgumentPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)\=';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigPropertyPattern.php:
--------------------------------------------------------------------------------
1 | [\w]+)';
20 | }
21 |
22 | public function getTokenType(): TokenTypeEnum
23 | {
24 | return TokenTypeEnum::PROPERTY;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigSingleQuoteValuePattern.php:
--------------------------------------------------------------------------------
1 | .*?)'";
23 | }
24 |
25 | public function getTokenType(): TokenTypeEnum
26 | {
27 | return TokenTypeEnum::VALUE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Languages/Twig/Patterns/TwigTokenPattern.php:
--------------------------------------------------------------------------------
1 | {$this->regex})/";
24 | }
25 |
26 | public function getTokenType(): TokenTypeEnum
27 | {
28 | return $this->type;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Languages/Twig/TwigLanguage.php:
--------------------------------------------------------------------------------
1 | ', output: 'attr')]
13 | #[PatternTest(input: '', output: 'href')]
14 | #[PatternTest(input: '', output: 'data-type')]
15 | final readonly class XmlAttributePattern implements Pattern
16 | {
17 | use IsPattern;
18 |
19 | public function getPattern(): string
20 | {
21 | return '(?[\w\-]+)="';
22 | }
23 |
24 | public function getTokenType(): TokenTypeEnum
25 | {
26 | return TokenTypeEnum::PROPERTY;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Languages/Xml/Patterns/XmlCloseTagPattern.php:
--------------------------------------------------------------------------------
1 | ', output: 'x-hello')]
13 | #[PatternTest(input: ' ', output: 'a')]
14 | final readonly class XmlCloseTagPattern implements Pattern
15 | {
16 | use IsPattern;
17 |
18 | public function getPattern(): string
19 | {
20 | return '<\/(?[\w\-]+)';
21 | }
22 |
23 | public function getTokenType(): TokenTypeEnum
24 | {
25 | return TokenTypeEnum::KEYWORD;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Languages/Xml/Patterns/XmlCommentPattern.php:
--------------------------------------------------------------------------------
1 |
17 | test',
18 | output: ''
21 | )]
22 | #[PatternTest(input: '