diff options
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/v2/lexers/php.go')
| -rw-r--r-- | vendor/github.com/alecthomas/chroma/v2/lexers/php.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/php.go b/vendor/github.com/alecthomas/chroma/v2/lexers/php.go new file mode 100644 index 0000000..ff82f6e --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/php.go | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | package lexers | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "strings" | ||
| 5 | |||
| 6 | . "github.com/alecthomas/chroma/v2" // nolint | ||
| 7 | ) | ||
| 8 | |||
| 9 | // phtml lexer is PHP in HTML. | ||
| 10 | var _ = Register(DelegatingLexer(HTML, MustNewLexer( | ||
| 11 | &Config{ | ||
| 12 | Name: "PHTML", | ||
| 13 | Aliases: []string{"phtml"}, | ||
| 14 | Filenames: []string{"*.phtml", "*.php", "*.php[345]", "*.inc"}, | ||
| 15 | MimeTypes: []string{"application/x-php", "application/x-httpd-php", "application/x-httpd-php3", "application/x-httpd-php4", "application/x-httpd-php5", "text/x-php"}, | ||
| 16 | DotAll: true, | ||
| 17 | CaseInsensitive: true, | ||
| 18 | EnsureNL: true, | ||
| 19 | Priority: 2, | ||
| 20 | }, | ||
| 21 | func() Rules { | ||
| 22 | return Get("PHP").(*RegexLexer).MustRules(). | ||
| 23 | Rename("root", "php"). | ||
| 24 | Merge(Rules{ | ||
| 25 | "root": { | ||
| 26 | {`<\?(php)?`, CommentPreproc, Push("php")}, | ||
| 27 | {`[^<]+`, Other, nil}, | ||
| 28 | {`<`, Other, nil}, | ||
| 29 | }, | ||
| 30 | }) | ||
| 31 | }, | ||
| 32 | ).SetAnalyser(func(text string) float32 { | ||
| 33 | if strings.Contains(text, "<?php") { | ||
| 34 | return 0.5 | ||
| 35 | } | ||
| 36 | return 0.0 | ||
| 37 | }))) | ||
