lexers.go

 1// Package lexers contains the registry of all lexers.
 2//
 3// Sub-packages contain lexer implementations.
 4package lexers
 5
 6// nolint: golint
 7import (
 8	"github.com/alecthomas/chroma"
 9	_ "github.com/alecthomas/chroma/lexers/a"
10	_ "github.com/alecthomas/chroma/lexers/b"
11	_ "github.com/alecthomas/chroma/lexers/c"
12	_ "github.com/alecthomas/chroma/lexers/circular"
13	_ "github.com/alecthomas/chroma/lexers/d"
14	_ "github.com/alecthomas/chroma/lexers/e"
15	_ "github.com/alecthomas/chroma/lexers/f"
16	_ "github.com/alecthomas/chroma/lexers/g"
17	_ "github.com/alecthomas/chroma/lexers/h"
18	_ "github.com/alecthomas/chroma/lexers/i"
19	"github.com/alecthomas/chroma/lexers/internal"
20	_ "github.com/alecthomas/chroma/lexers/j"
21	_ "github.com/alecthomas/chroma/lexers/k"
22	_ "github.com/alecthomas/chroma/lexers/l"
23	_ "github.com/alecthomas/chroma/lexers/m"
24	_ "github.com/alecthomas/chroma/lexers/n"
25	_ "github.com/alecthomas/chroma/lexers/o"
26	_ "github.com/alecthomas/chroma/lexers/p"
27	_ "github.com/alecthomas/chroma/lexers/q"
28	_ "github.com/alecthomas/chroma/lexers/r"
29	_ "github.com/alecthomas/chroma/lexers/s"
30	_ "github.com/alecthomas/chroma/lexers/t"
31	_ "github.com/alecthomas/chroma/lexers/v"
32	_ "github.com/alecthomas/chroma/lexers/w"
33	_ "github.com/alecthomas/chroma/lexers/x"
34	_ "github.com/alecthomas/chroma/lexers/y"
35)
36
37// Registry of Lexers.
38var Registry = internal.Registry
39
40// Names of all lexers, optionally including aliases.
41func Names(withAliases bool) []string { return internal.Names(withAliases) }
42
43// Get a Lexer by name, alias or file extension.
44func Get(name string) chroma.Lexer { return internal.Get(name) }
45
46// MatchMimeType attempts to find a lexer for the given MIME type.
47func MatchMimeType(mimeType string) chroma.Lexer { return internal.MatchMimeType(mimeType) }
48
49// Match returns the first lexer matching filename.
50func Match(filename string) chroma.Lexer { return internal.Match(filename) }
51
52// Analyse text content and return the "best" lexer..
53func Analyse(text string) chroma.Lexer { return internal.Analyse(text) }
54
55// Register a Lexer with the global registry.
56func Register(lexer chroma.Lexer) chroma.Lexer { return internal.Register(lexer) }
57
58// Fallback lexer if no other is found.
59var Fallback = internal.Fallback