mirror of
https://github.com/alecthomas/chroma.git
synced 2025-04-11 11:32:05 +02:00
parent
ccd8d68495
commit
9087c632c4
@ -30,6 +30,9 @@ func Names(withAliases bool) []string {
|
||||
}
|
||||
|
||||
// Get a Lexer by name, alias or file extension.
|
||||
//
|
||||
// Note that this if there isn't an exact match on name or alias, this will
|
||||
// call Match(), so it is not efficient.
|
||||
func Get(name string) chroma.Lexer {
|
||||
return GlobalLexerRegistry.Get(name)
|
||||
}
|
||||
@ -40,6 +43,9 @@ func MatchMimeType(mimeType string) chroma.Lexer {
|
||||
}
|
||||
|
||||
// Match returns the first lexer matching filename.
|
||||
//
|
||||
// Note that this iterates over all file patterns in all lexers, so it's not
|
||||
// particularly efficient.
|
||||
func Match(filename string) chroma.Lexer {
|
||||
return GlobalLexerRegistry.Match(filename)
|
||||
}
|
||||
|
@ -179,7 +179,6 @@ func FileTestAnalysis(t *testing.T, lexer chroma.Lexer, actualFilepath, expected
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, f.Close())
|
||||
} else {
|
||||
// fail via an assertion of string comparison for nicer diff output
|
||||
assert.Equal(t, string(expectedData), actualData.String())
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ func (l *LexerRegistry) MatchMimeType(mimeType string) Lexer {
|
||||
}
|
||||
|
||||
// Match returns the first lexer matching filename.
|
||||
//
|
||||
// Note that this iterates over all file patterns in all lexers, so is not fast.
|
||||
func (l *LexerRegistry) Match(filename string) Lexer {
|
||||
filename = filepath.Base(filename)
|
||||
matched := PrioritisedLexers{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user