diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-10-25 00:47:47 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-10-25 00:47:47 +0200 |
| commit | c6cc0108ca7738023b45e0eeac0fa2390532dd93 (patch) | |
| tree | 36890e6cd3091bbab8efbe686cc56f467f645bfd /vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go | |
| parent | 0130404a1dc663d4aa68d780c9bcb23a4243e68d (diff) | |
| download | jbmafp-c6cc0108ca7738023b45e0eeac0fa2390532dd93.tar.gz | |
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go')
| -rw-r--r-- | vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go b/vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go new file mode 100644 index 0000000..38e0245 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | package lexers | ||
| 2 | |||
| 3 | import ( | ||
| 4 | . "github.com/alecthomas/chroma/v2" // nolint | ||
| 5 | ) | ||
| 6 | |||
| 7 | // Smarty lexer. | ||
| 8 | var Smarty = Register(MustNewLexer( | ||
| 9 | &Config{ | ||
| 10 | Name: "Smarty", | ||
| 11 | Aliases: []string{"smarty"}, | ||
| 12 | Filenames: []string{"*.tpl"}, | ||
| 13 | MimeTypes: []string{"application/x-smarty"}, | ||
| 14 | DotAll: true, | ||
| 15 | }, | ||
| 16 | smartyRules, | ||
| 17 | )) | ||
| 18 | |||
| 19 | func smartyRules() Rules { | ||
| 20 | return Rules{ | ||
| 21 | "root": { | ||
| 22 | {`[^{]+`, Other, nil}, | ||
| 23 | {`(\{)(\*.*?\*)(\})`, ByGroups(CommentPreproc, Comment, CommentPreproc), nil}, | ||
| 24 | {`(\{php\})(.*?)(\{/php\})`, ByGroups(CommentPreproc, Using("PHP"), CommentPreproc), nil}, | ||
| 25 | {`(\{)(/?[a-zA-Z_]\w*)(\s*)`, ByGroups(CommentPreproc, NameFunction, Text), Push("smarty")}, | ||
| 26 | {`\{`, CommentPreproc, Push("smarty")}, | ||
| 27 | }, | ||
| 28 | "smarty": { | ||
| 29 | {`\s+`, Text, nil}, | ||
| 30 | {`\{`, CommentPreproc, Push()}, | ||
| 31 | {`\}`, CommentPreproc, Pop(1)}, | ||
| 32 | {`#[a-zA-Z_]\w*#`, NameVariable, nil}, | ||
| 33 | {`\$[a-zA-Z_]\w*(\.\w+)*`, NameVariable, nil}, | ||
| 34 | {`[~!%^&*()+=|\[\]:;,.<>/?@-]`, Operator, nil}, | ||
| 35 | {`(true|false|null)\b`, KeywordConstant, nil}, | ||
| 36 | {`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil}, | ||
| 37 | {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, | ||
| 38 | {`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, | ||
| 39 | {`[a-zA-Z_]\w*`, NameAttribute, nil}, | ||
| 40 | }, | ||
| 41 | } | ||
| 42 | } | ||
