1package lexers
 2
 3import (
 4	"strings"
 5
 6	. "github.com/alecthomas/chroma/v2" // nolint
 7)
 8
 9// ERB lexer is Ruby embedded in HTML.
10var ERB = Register(DelegatingLexer(HTML, MustNewXMLLexer(
11	embedded,
12	"embedded/erb.xml",
13).SetConfig(
14	&Config{
15		Name:      "ERB",
16		Aliases:   []string{"erb", "html+erb", "html+ruby", "rhtml"},
17		Filenames: []string{"*.erb", "*.html.erb", "*.xml.erb", "*.rhtml"},
18		MimeTypes: []string{"application/x-ruby-templating"},
19		DotAll:    true,
20	},
21).SetAnalyser(func(text string) float32 {
22	if strings.Contains(text, "<%=") && strings.Contains(text, "%>") {
23		return 0.4
24	}
25	if strings.Contains(text, "<%") {
26		return 0.1
27	}
28	return 0.0
29})))