highlight¶
Print the content of FILE with syntax highlighting.
With no FILE, or when FILE is -, read standard input.
highlight [OPTIONS] [FILE]
Options
-
-m,--mime<mime>¶ The MIME time to use for highlighting.
-
-l,--lexer<lexer>¶ The Pygments lexer to use for highlighting.
-
-T,--show-tabs¶ Display TAB characters as ^I.
-
-E,--show-ends¶ Display $ at the end of each line.
-
-n,--number¶ Number all output lines.
-
-D,--debug¶ Print the lexer name to stderr.
-
--version¶ Show the version and exit.
Arguments
-
FILE¶ Optional argument. Default
None
Notes
If no
--lexeror--mimeoption is given, the lexer is determined fromFILE. If reading from standard input, of if the file extension is unknown, the lexer is determined by examining the file’s contents.If the
--mimeoption is given but no lexer can be found for that mime type the mime type is ignored.See https://pygments.org/docs/lexers/ for a list of available lexers.
Examples¶
Highlight a Python source code file.
highlight code.py
Highlight a Ruby source code file with the RubyConsoleLexer.
highlight code.rb --lexer rbcon
Highlight a Rust source code file with line numbers.
highlight main.rs --number