LinuxCommandLibrary

chroma

Chroma is a general-purpose syntax highlighting library and corresponding command, for Go.

TLDR

Highlight source code from a file with the Python lexer and output to stdout

$ chroma --lexer [python] [path/to/source_file.py]
copy


Highlight source code from a file with the Go lexer and output to an HTML file
$ chroma --lexer [go] --formatter [html] [path/to/source_file.go] > [path/to/target_file.html]
copy


Highlight source code from stdin with the C++ lexer and output to an SVG file, using the Monokai style
$ [command] | chroma --lexer [c++] --formatter [svg] --style [monokai] > [path/to/target_file.svg]
copy


List available lexers, styles and formatters
$ chroma --list
copy

SYNOPSIS

chroma [options] files ...

DESCRIPTION

This manual page documents briefly the chroma command.

OPTIONS

These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below.

–help

Show context-sensitive help.

–list

List lexers, styles and formatters.

–unbuffered

Do not buffer output.

–trace

Trace lexer states as they are traversed.

–check

Do not format, check for tokenization errors instead.

–filename=FILENAME

Filename to use for selecting a lexer when reading from stdin.

-l, –lexer=autodetect

Lexer to use when formatting.

-s, –style=swapoff

Style to use for formatting.

-f, –formatter=terminal

Formatter to use.

–html

Enable HTML mode (equivalent to `–formatter html').

–html-prefix=PREFIX

HTML CSS class prefix.

–html-styles

Output HTML CSS styles.

–html-only

Output HTML fragment.

–html-inline-styles

Output HTML with inline styles (no classes).

–html-tab-width=8

Set the HTML tab width.

–html-lines

Include line numbers in output.

–html-lines-table

Split line numbers and code in a HTML table

–html-lines-style=HTML-LINES-STYLE

Style for line numbers.

–html-highlight=N[:M][,...]

Highlight these lines.

–html-highlight-style=HTML-HIGHLIGHT-STYLE

Style used for highlighting lines.

–html-base-line=1

Base line number.

–version

Show application version.

BUGS

See GitHub Issues: <https://github.com/alecthomas/chroma/issues>

Copied to clipboard