2025-03-14 21:59:59 -06:00
|
|
|
# chroma
|
|
|
|
|
|
|
|
|
|
> A general-purpose syntax highlighter.
|
|
|
|
|
> The `--lexer` option is usually unnecessary, as it will be automatically determined based on the file extension.
|
2026-02-18 06:55:01 -07:00
|
|
|
> More information: <https://manned.org/chroma>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Highlight source code from a file with the Python lexer and output to `stdout`:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`chroma {{[-l|--lexer]}} {{python}} {{path/to/source_file.py}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Highlight source code from a file with the Go lexer and output to an HTML file:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`chroma {{[-l|--lexer]}} {{go}} {{[-f|--formatter]}} {{html}} {{path/to/source_file.go}} > {{path/to/target_file.html}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Highlight source code from `stdin` with the C++ lexer and output to an SVG file, using the Monokai style:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`{{command}} | chroma {{[-l|--lexer]}} {{c++}} {{[-f|--formatter]}} {{svg}} {{[-s|--style]}} {{monokai}} > {{path/to/target_file.svg}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- List available lexers, styles, and formatters:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
`chroma --list`
|