Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 780 Bytes

specify-the-language-for-a-file-with-bat.md

File metadata and controls

19 lines (13 loc) · 780 Bytes

Specify The Language For A File With Bat

The bat utility is able to correctly infer the language of most files it prints based on the file extension. In some cases, you may want to specify a language other than the one it guesses.

For instance, here is a React file printed with bat:

bat with no CLI args

The jsx syntax doesn't look great because of the inferred language highlighting doesn't account for it. We can get better results by telling bat that the file should be parsed as JavaScript (Babel).

bat with language specified

By including --language=jsx as a flag, bat uses a different language parser and the output is now what I'm looking for.