chroma: update page (#10202)

pull/23/head
Lena 2023-05-17 17:55:34 +02:00 committed by GitHub
parent 56c232b361
commit 4ccd83fa92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -1,16 +1,21 @@
# chroma
> Chroma is a general-purpose syntax highlighting library and corresponding command, for Go.
> A general-purpose syntax highlighter.
> The `--lexer` option is usually unnecessary, as it will be automatically determined based on the file extension.
> More information: <https://github.com/alecthomas/chroma>.
- Highlight a source file with Python lexer and output to terminal:
- Highlight source code from a file with the Python lexer and output to `stdout`:
`chroma --lexer="{{python}}" {{source_file}}`
`chroma --lexer {{python}} {{path/to/source_file.py}}`
- Highlight a source file with the Go lexer and output to an HTML file:
- Highlight source code from a file with the Go lexer and output to an HTML file:
`chroma --lexer="{{go}}" --formatter="{{html}}" {{source_file}} > {{html_file}}`
`chroma --lexer {{go}} --formatter {{html}} {{path/to/source_file.go}} > {{path/to/target_file.html}}`
- Highlight a source file with the C++ lexer and output to an SVG, using the Monokai style:
- Highlight source code from `stdin` with the C++ lexer and output to an SVG file, using the Monokai style:
`chroma --lexer="{{c++}}" --formatter="{{svg}}" --style="{{monokai}}" {{source_file}} > {{svg_file}}`
`{{command}} | chroma --lexer {{c++}} --formatter {{svg}} --style {{monokai}} > {{path/to/target_file.svg}}`
- List available lexers, styles and formatters:
`chroma --list`