prettyprint

Syntax highlighting library with batteries included.

Quick start

Screenshot

The above output was created with the following code:

```rust let printer = PrettyPrinter::default() .language("rust") .build()?;

printer.file("fixtures/fib.rs")?; ```

Note that prettyprint is a builder and can be customized. For example, if you don't like the grid or the header, you can disable those:

```rust 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.stringwithheader(example, "fib.rb")?; ```

"What!? It can also print strings, Matthias? That's insane."
It's true. You're welcome.

Installation

Add this to your Cargo.toml:

TOML prettyprint = "*"

But why?

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.

prettyprint offers all of this in one crate.

Known limitations

Credits

prettyprint is simply a fork of bat, with some functionality stripped out and bundled up as a library. I built it, because I needed it for cargo-inspect. All credits go to the original authors.