2 unstable releases
|0.2.0||Nov 30, 2018|
|0.1.0||Nov 29, 2018|
#9 in #syntax
9 downloads per month
Used in 1 crate
Syntax highlighting library with batteries included.
The above output was created with the following code:
let printer = PrettyPrinter::default() .language("rust") .build()?; printer.file("fixtures/fib.rs")?;
prettyprint is a builder and can be customized. For example, if you don't like the grid or the header, you can disable those:
let printer = PrettyPrinter::default() .header(false) .grid(false) .language("ruby") .build()?; let example = r#" def fib(n) return 1 if n <= 1 fib(n-1) + fib(n-2) end "#; printer.string_with_header(example, "fib.rb")?;
"What!? It can also print strings, Matthias? That's insane."
It's true. You're welcome.
Add this to your
prettyprint = "*"
syntect is a great package for highlighting text.
When writing a command-line tool that prints text however, you might be looking for some additional functionality.
- Line numbers
- More built-in color-themes
- Automatic pagination
- Proper terminal handling
- Showing non-printable characters
- File headers
- Windows support
prettyprint offers all of this in one crate.
- Doesn't run on
no-stdtargets. I don't plan to support those.