summaryrefslogtreecommitdiff
path: root/vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-10-25 00:47:47 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-10-25 00:47:47 +0200
commitc6cc0108ca7738023b45e0eeac0fa2390532dd93 (patch)
tree36890e6cd3091bbab8efbe686cc56f467f645bfd /vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go
parent0130404a1dc663d4aa68d780c9bcb23a4243e68d (diff)
downloadjbmafp-master.tar.gz
Added vendor lock on depsHEADmaster
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go')
-rw-r--r--vendor/github.com/alecthomas/chroma/v2/lexers/smarty.go42
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 @@
+package lexers
+
+import (
+ . "github.com/alecthomas/chroma/v2" // nolint
+)
+
+// Smarty lexer.
+var Smarty = Register(MustNewLexer(
+ &Config{
+ Name: "Smarty",
+ Aliases: []string{"smarty"},
+ Filenames: []string{"*.tpl"},
+ MimeTypes: []string{"application/x-smarty"},
+ DotAll: true,
+ },
+ smartyRules,
+))
+
+func smartyRules() Rules {
+ return Rules{
+ "root": {
+ {`[^{]+`, Other, nil},
+ {`(\{)(\*.*?\*)(\})`, ByGroups(CommentPreproc, Comment, CommentPreproc), nil},
+ {`(\{php\})(.*?)(\{/php\})`, ByGroups(CommentPreproc, Using("PHP"), CommentPreproc), nil},
+ {`(\{)(/?[a-zA-Z_]\w*)(\s*)`, ByGroups(CommentPreproc, NameFunction, Text), Push("smarty")},
+ {`\{`, CommentPreproc, Push("smarty")},
+ },
+ "smarty": {
+ {`\s+`, Text, nil},
+ {`\{`, CommentPreproc, Push()},
+ {`\}`, CommentPreproc, Pop(1)},
+ {`#[a-zA-Z_]\w*#`, NameVariable, nil},
+ {`\$[a-zA-Z_]\w*(\.\w+)*`, NameVariable, nil},
+ {`[~!%^&*()+=|\[\]:;,.<>/?@-]`, Operator, nil},
+ {`(true|false|null)\b`, KeywordConstant, nil},
+ {`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
+ {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
+ {`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
+ {`[a-zA-Z_]\w*`, NameAttribute, nil},
+ },
+ }
+}