Mercurial > yakumo_izuru > aya
comparison vendor/github.com/alecthomas/chroma/v2/lexers/php.go @ 66:787b5ee0289d draft
Use vendored modules
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Sun, 23 Jul 2023 13:18:53 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
65:6d985efa0f7a | 66:787b5ee0289d |
---|---|
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 }))) |