mirror of
https://github.com/cheat/cheat.git
synced 2025-09-02 01:58:29 +02:00
Add vendor files for go build
This commit is contained in:
44
vendor/github.com/alecthomas/chroma/quick/quick.go
generated
vendored
Normal file
44
vendor/github.com/alecthomas/chroma/quick/quick.go
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
// Package quick provides simple, no-configuration source code highlighting.
|
||||
package quick
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/alecthomas/chroma"
|
||||
"github.com/alecthomas/chroma/formatters"
|
||||
"github.com/alecthomas/chroma/lexers"
|
||||
"github.com/alecthomas/chroma/styles"
|
||||
)
|
||||
|
||||
// Highlight some text.
|
||||
//
|
||||
// Lexer, formatter and style may be empty, in which case a best-effort is made.
|
||||
func Highlight(w io.Writer, source, lexer, formatter, style string) error {
|
||||
// Determine lexer.
|
||||
l := lexers.Get(lexer)
|
||||
if l == nil {
|
||||
l = lexers.Analyse(source)
|
||||
}
|
||||
if l == nil {
|
||||
l = lexers.Fallback
|
||||
}
|
||||
l = chroma.Coalesce(l)
|
||||
|
||||
// Determine formatter.
|
||||
f := formatters.Get(formatter)
|
||||
if f == nil {
|
||||
f = formatters.Fallback
|
||||
}
|
||||
|
||||
// Determine style.
|
||||
s := styles.Get(style)
|
||||
if s == nil {
|
||||
s = styles.Fallback
|
||||
}
|
||||
|
||||
it, err := l.Tokenise(nil, source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f.Format(w, s, it)
|
||||
}
|
Reference in New Issue
Block a user