Crates.io | code_highlighter |
lib.rs | code_highlighter |
version | 0.2.0 |
source | src |
created_at | 2024-07-26 21:42:02.760044 |
updated_at | 2024-09-06 00:32:36.825452 |
description | Highlights code for printing |
homepage | |
repository | https://github.com/yazaldefilimone/code_highlighter.rs |
max_upload_size | |
id | 1316788 |
size | 68,611 |
Rust util that highlights an error.
Example
The code below:
let code = "functon is_zero (x) {
if (x == 0) [
return true;
] else {
return false;
}
}";
println!("Error:");
println!("{}", code_highlighter::highlight_error(38, 64, &code));
println!("");
println!("Warning:");
println!("{}", code_highlighter::highlight_warning(38, 64, &code));
println!("");
println!("Custom color:");
println!("{}", code_highlighter::highlight(38, 64, &code, "\x1b[4m\x1b[32m"));
println!("");
let code = "(Foo x) = 7[0 ]\n";
println!("Error:");
println!("{}", code_highlighter::highlight_error(16, 17, &code));
println!("");
Will output:
A fork of highlight_error 🥺