-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
196 additions
and
20 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/MarkDown/CustomHL/Languages/JavaScript/Injections/JsSingleQuoteValue2Injection.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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\MarkDown\CustomHL\Languages\JavaScript\Injections; | ||
|
||
use Tempest\Highlight\Highlighter; | ||
use Tempest\Highlight\Injection; | ||
use Tempest\Highlight\IsInjection; | ||
use Tempest\Highlight\Escape; | ||
use Tempest\Highlight\Tokens\DynamicTokenType; | ||
|
||
final readonly class JsSingleQuoteValue2Injection implements Injection | ||
{ | ||
use IsInjection; | ||
|
||
public function getPattern(): string | ||
{ | ||
return "(?<match>`.*?`)"; | ||
} | ||
|
||
public function parseContent(string $content, Highlighter $highlighter): string | ||
{ | ||
$theme = $highlighter->getTheme(); | ||
|
||
$clear_content = Escape::terminal($content); | ||
|
||
return Escape::injection( | ||
Escape::tokens($theme->before(new DynamicTokenType('hl-js-value'))) | ||
. $clear_content | ||
. Escape::tokens($theme->after(new DynamicTokenType('hl-js-value'))) | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/MarkDown/CustomHL/Languages/JavaScript/Injections/JsSingleQuoteValueInjection.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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\MarkDown\CustomHL\Languages\JavaScript\Injections; | ||
|
||
use Tempest\Highlight\Highlighter; | ||
use Tempest\Highlight\Injection; | ||
use Tempest\Highlight\IsInjection; | ||
use Tempest\Highlight\Escape; | ||
use Tempest\Highlight\Tokens\DynamicTokenType; | ||
|
||
final readonly class JsSingleQuoteValueInjection implements Injection | ||
{ | ||
use IsInjection; | ||
|
||
public function getPattern(): string | ||
{ | ||
return "(?<match>'.*?')"; | ||
} | ||
|
||
public function parseContent(string $content, Highlighter $highlighter): string | ||
{ | ||
$theme = $highlighter->getTheme(); | ||
|
||
$clear_content = Escape::terminal($content); | ||
|
||
return Escape::injection( | ||
Escape::tokens($theme->before(new DynamicTokenType('hl-js-value'))) | ||
. $clear_content | ||
. Escape::tokens($theme->after(new DynamicTokenType('hl-js-value'))) | ||
); | ||
} | ||
} |
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
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
25 changes: 25 additions & 0 deletions
25
app/MarkDown/CustomHL/Languages/JavaScript/Patterns/JsMultilineCommentPattern.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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\MarkDown\CustomHL\Languages\JavaScript\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\Tokens\TokenType; | ||
use Tempest\Highlight\Tokens\DynamicTokenType; | ||
|
||
final readonly class JsMultilineCommentPattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '/(?<match>\/\*(.|\n)*?\*\/)/m'; | ||
} | ||
|
||
public function getTokenType(): TokenType | ||
{ | ||
return new DynamicTokenType('hl-js-comment'); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
app/MarkDown/CustomHL/Languages/Json/Patterns/DigitsValuePattern.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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\MarkDown\CustomHL\Languages\Json\Patterns; | ||
|
||
use Tempest\Highlight\IsPattern; | ||
use Tempest\Highlight\Pattern; | ||
use Tempest\Highlight\Tokens\TokenType; | ||
use Tempest\Highlight\Tokens\DynamicTokenType; | ||
|
||
final readonly class DigitsValuePattern implements Pattern | ||
{ | ||
use IsPattern; | ||
|
||
public function getPattern(): string | ||
{ | ||
return '/\:(\s)*(?<match>[0-9.]+)/'; | ||
} | ||
|
||
public function getTokenType(): TokenType | ||
{ | ||
return new DynamicTokenType('hl-js-number'); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.