LinuxCommandLibrary

highlight

converts source code to formatted output with syntax highlighting

TLDR

Highlight source code
$ highlight [file.py]
copy
Output as HTML
$ highlight -O html [file.py] > [file.html]
copy
Output as ANSI (terminal)
$ highlight -O ansi [file.py]
copy
Specify language
$ highlight --syntax=[python] [file]
copy
Use specific theme
$ highlight --style=[molokai] [file.py]
copy
List supported languages
$ highlight --list-scripts=langs
copy
List available themes
$ highlight --list-scripts=themes
copy

SYNOPSIS

highlight [options] [files...]

DESCRIPTION

highlight converts source code to formatted output with syntax highlighting. It supports over 200 programming languages and can output to HTML, ANSI, RTF, LaTeX, and other formats.
The tool is useful for documentation, presentations, and generating printable source listings with proper syntax coloring.

PARAMETERS

-O format

Output format (html, ansi, xhtml, rtf, latex, tex, svg).
-S, --syntax lang
Specify source language.
-s, --style name
Color theme.
-l, --line-numbers
Include line numbers.
-i, --input file
Input file.
-o, --output file
Output file.
--list-scripts type
List langs, themes, or plugins.
-f, --fragment
Omit document headers.
--inline-css
Embed CSS in HTML.

CAVEATS

Language detection may need hints. Theme appearance varies by output format. Some languages have limited support.

HISTORY

highlight was created by Andre Simon as a universal source code highlighter. It has been actively developed since 2002, continuously adding language support and output formats.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard