pygmentize
Rust library and wrapper around the pygmentize CLI. Apply syntax highlighting to over 500 languages and other text formatted. Render into HTML, SVG, LaTeX, and Terminal (ANSI color sequences).
Example
use ;
let code = r#"fn main() {
println!("Hello, world!");
}"#;
let html = highlight?;
println!;
Output
(whitespace added to improve clarity)
"Hello, world!"
);
}
fn
main
()
{
println!
(
Rendered
(with the Dracula theme)
Install
The library is a wrapper around the pygmentize CLI, and as such it must be available in the system PATH. The easiest way to install pygmentize is through Python.
pip install Pygments