mirror of
https://github.com/alecthomas/chroma.git
synced 2026-05-22 10:15:46 +02:00
Document and add iterator panic recovery.
This commit is contained in:
@@ -18,9 +18,6 @@ func main() {
|
||||
kingpin.CommandLine.Help = "Exercise linters against a list of files."
|
||||
kingpin.Parse()
|
||||
|
||||
writer, err := formatters.NoOp.Format(ioutil.Discard, styles.SwapOff)
|
||||
kingpin.FatalIfError(err, "")
|
||||
|
||||
for _, file := range *filesArgs {
|
||||
lexer := lexers.Match(file)
|
||||
if lexer == nil {
|
||||
@@ -29,8 +26,10 @@ func main() {
|
||||
}
|
||||
text, err := ioutil.ReadFile(file)
|
||||
kingpin.FatalIfError(err, "")
|
||||
err = lexer.Tokenise(nil, string(text), writer)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user