forked from tempestphp/highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScssKeywordPattern.php
More file actions
33 lines (27 loc) · 1.07 KB
/
ScssKeywordPattern.php
File metadata and controls
33 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace Tempest\Highlight\Languages\Scss\Patterns;
use Tempest\Highlight\IsPattern;
use Tempest\Highlight\Pattern;
use Tempest\Highlight\PatternTest;
use Tempest\Highlight\Tokens\TokenTypeEnum;
#[PatternTest(input: '@mixin rounded {', output: '@mixin')]
#[PatternTest(input: '@include rounded;', output: '@include')]
#[PatternTest(input: '@extend .base;', output: '@extend')]
#[PatternTest(input: '@if $dark {', output: '@if')]
#[PatternTest(input: '@each $color in $colors {', output: '@each')]
#[PatternTest(input: "@use 'colors';", output: '@use')]
#[PatternTest(input: '@function double($value) {', output: '@function')]
#[PatternTest(input: '@return $value * 2;', output: '@return')]
final readonly class ScssKeywordPattern implements Pattern
{
use IsPattern;
public function getPattern(): string
{
return '(?<match>@(?:mixin|include|extend|function|return|if|else|for|each|while|use|forward|at-root|debug|warn|error))\b';
}
public function getTokenType(): TokenTypeEnum
{
return TokenTypeEnum::KEYWORD;
}
}