LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

chroma

general purpose syntax highlighter

TLDR

Highlight source file
$ chroma [file.go]
copy
Specify language
$ chroma -l python [file.py]
copy
HTML output
$ chroma --html [file.js] > [output.html]
copy
List available lexers
$ chroma --list
copy
Use specific style
$ chroma -s monokai [file.rb]
copy
HTML with inline styles
$ chroma --html --html-inline-styles [file.c]
copy

SYNOPSIS

chroma [options] [file...]

DESCRIPTION

chroma is a general-purpose syntax highlighter supporting approximately 250 languages. It converts source code to syntax-highlighted HTML, ANSI-colored terminal output, SVG, and other formats.The tool is based on the Pygments highlighting engine but reimplemented in Go for speed and easy embedding. It supports numerous color styles (monokai, dracula, github, etc.) and can autodetect the language from filenames and content. Chroma is also available as a Go library, used by tools like Hugo for code highlighting.

PARAMETERS

-l, --lexer name

Lexer to use (default: autodetect)
-s, --style name
Highlighting style
-f, --formatter name
Output formatter: terminal, terminal256, terminal16m, html
--html
Enable HTML mode
--html-only
Output HTML fragment only
--html-inline-styles
Inline CSS styles (no classes)
--list
List lexers, styles, formatters
--fail
Exit with status 1 if lexer not found

USAGE WITH LESS

$ export LESSOPEN='| chroma --fail "$1" || cat "$1"; "%s"'
copy

INSTALL

sudo apt install golang-chroma
copy
brew install chroma
copy
nix profile install nixpkgs#chroma
copy

CAVEATS

Autodetects language from filename and content. Use --fail for fallback pipelines.

SEE ALSO

highlight(1), pygmentize(1), bat(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid