mirror of
https://github.com/alecthomas/chroma.git
synced 2025-04-15 11:46:38 +02:00
parent
ccd8d68495
commit
9087c632c4
@ -30,6 +30,9 @@ func Names(withAliases bool) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a Lexer by name, alias or file extension.
|
// 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 {
|
func Get(name string) chroma.Lexer {
|
||||||
return GlobalLexerRegistry.Get(name)
|
return GlobalLexerRegistry.Get(name)
|
||||||
}
|
}
|
||||||
@ -40,6 +43,9 @@ func MatchMimeType(mimeType string) chroma.Lexer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Match returns the first lexer matching filename.
|
// 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 {
|
func Match(filename string) chroma.Lexer {
|
||||||
return GlobalLexerRegistry.Match(filename)
|
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, err)
|
||||||
assert.NoError(t, f.Close())
|
assert.NoError(t, f.Close())
|
||||||
} else {
|
} else {
|
||||||
// fail via an assertion of string comparison for nicer diff output
|
|
||||||
assert.Equal(t, string(expectedData), actualData.String())
|
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.
|
// 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 {
|
func (l *LexerRegistry) Match(filename string) Lexer {
|
||||||
filename = filepath.Base(filename)
|
filename = filepath.Base(filename)
|
||||||
matched := PrioritisedLexers{}
|
matched := PrioritisedLexers{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user