Linux command
pygmentize 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Highlight code file
pygmentize [file.py]
Specify output format
pygmentize -f [html] [file.py]
Output to file
pygmentize -o [output.html] [file.py]
Specify language
pygmentize -l [python] [file]
List available lexers
pygmentize -L lexers
Generate CSS
pygmentize -S [monokai] -f html > [style.css]
说明
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.
参数
- -f _FORMATTER_
- Output format.
- -l _LEXER_
- Language lexer.
- -o _FILE_
- Output file.
- -S _STYLE_
- Syntax style.
- -L
- List available options.
FAQ
What is the pygmentize command used for?
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.
How do I run a basic pygmentize example?
Run `pygmentize [file.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f _FORMATTER_ do in pygmentize?
Output format.