code_highlighter

Crates.iocode_highlighter
lib.rscode_highlighter
version0.2.0
sourcesrc
created_at2024-07-26 21:42:02.760044
updated_at2024-09-06 00:32:36.825452
descriptionHighlights code for printing
homepage
repositoryhttps://github.com/yazaldefilimone/code_highlighter.rs
max_upload_size
id1316788
size68,611
Yazalde Filimone (yazaldefilimone)

documentation

README

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:

example

A fork of highlight_error 🥺

Commit count: 0

cargo fmt