mirror of
https://github.com/alecthomas/chroma.git
synced 2026-06-20 11:35:42 +02:00
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/alecthomas/chroma/formatters"
|
||||
"github.com/alecthomas/chroma/lexers"
|
||||
@@ -24,12 +25,14 @@ func main() {
|
||||
fmt.Printf("warning: could not find lexer for %q\n", file)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("%s: ", file)
|
||||
os.Stdout.Sync()
|
||||
text, err := ioutil.ReadFile(file)
|
||||
kingpin.FatalIfError(err, "")
|
||||
it, err := lexer.Tokenise(nil, string(text))
|
||||
kingpin.FatalIfError(err, "%s failed to tokenise %q", lexer.Config().Name, file)
|
||||
err = formatters.NoOp.Format(ioutil.Discard, styles.SwapOff, it)
|
||||
kingpin.FatalIfError(err, "%s failed to format %q", lexer.Config().Name, file)
|
||||
fmt.Printf("ok: %q\n", file)
|
||||
fmt.Printf("ok\n")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user