← 返回命令列表

Linux command

highlight 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Highlight source code

highlight [file.py]

Output as HTML

highlight -O html [file.py] > [file.html]

Output as ANSI

highlight -O ansi [file.py]

Specify language

highlight --syntax=[python] [file]

Use specific theme

highlight --style=[molokai] [file.py]

List supported languages

highlight --list-scripts=langs

List available themes

highlight --list-scripts=themes

说明

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.

参数

-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.

FAQ

What is the highlight command used for?

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.

How do I run a basic highlight example?

Run `highlight [file.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -O _format_ do in highlight?

Output format (html, ansi, xhtml, rtf, latex, tex, svg).