| Crates.io | ansi-pretty-print |
| lib.rs | ansi-pretty-print |
| version | 0.0.2 |
| created_at | 2025-11-21 12:15:27.315453+00 |
| updated_at | 2025-12-28 10:15:23.550382+00 |
| description | Pretty-printing structured data with ANSI color support and ligatures. Mostly used for debug outputs. |
| homepage | |
| repository | https://github.com/piot/ansi-pretty-print |
| max_upload_size | |
| id | 1943463 |
| size | 13,427 |
A Rust library for pretty-printing structured data with ANSI color support and ligatures. Mostly used for debug outputs for compilers.
Add this to your Cargo.toml:
[dependencies]
ansi-pretty-print = "0.0.1"
use ansi_pretty_print::Printer;
use std::fmt::Write;
let mut output = String::new();
let mut printer = Printer::new(&mut output)
.with_colors(true)
.with_ligature(true);
// Print with semantic coloring
printer.keyword("fn")?;
printer.write(" ")?;
printer.function_name("main")?;
printer.punctuation("()")?;
// Use blocks with automatic indentation
printer.block("", |p| {
p.line("println!(\"Hello, world!\");")?;
Ok(())
})?;
println!("{}", output);
Licensed under the MIT License. See LICENSE for details.
Copyright (c) 2025 Peter Bjorklund. All Rights Reserved.