LinuxCommandLibrary

pygmentize

Syntax highlight source code

TLDR

Highlight code file

$ pygmentize [file.py]
copy
Specify output format
$ pygmentize -f [html] [file.py]
copy
Output to file
$ pygmentize -o [output.html] [file.py]
copy
Specify language
$ pygmentize -l [python] [file]
copy
List available lexers
$ pygmentize -L lexers
copy
Generate CSS
$ pygmentize -S [monokai] -f html > [style.css]
copy

SYNOPSIS

pygmentize [options] [file]

DESCRIPTION

pygmentize is the command-line interface for the Pygments syntax highlighting library. It reads source code files and outputs syntax-highlighted versions in various formats including terminal ANSI colors, HTML, LaTeX, RTF, and SVG, supporting over 500 programming languages and markup formats.
The tool auto-detects the input language from file extensions or can be specified explicitly with -l. Output format is set with -f, and visual themes are controlled with -S for generating CSS stylesheets. pygmentize is widely used for generating highlighted code in documentation, blogs, and presentations.

PARAMETERS

FILE

Input file.
-f FORMATTER
Output format.
-l LEXER
Language lexer.
-o FILE
Output file.
-S STYLE
Syntax style.
-L
List available options.

CAVEATS

Python library required. Many output formats.

HISTORY

Pygments was created as a syntax highlighting library for Python.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community