1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
use json::JsonValue; use colored::*; mod generator; mod highlight_color; mod highlight; pub fn highlight(json_object: &JsonValue, mut slices: Vec<&JsonValue>) -> String { let mut gen = highlight::HighlightGenerator::new(); gen.write_json_with_highlight( json_object, &mut slices ).expect("Can't fail"); gen.consume() } pub fn highlight_with_colors(json_object: &JsonValue, mut slices: Vec<&JsonValue>, colors: Vec<Color>) -> String { let mut gen = highlight::HighlightGenerator::new_with_colors(colors); gen.write_json_with_highlight( json_object, &mut slices ).expect("Can't fail"); gen.consume() } pub fn highlight_with_colors_and_remainder(json_object: &JsonValue, mut slices: Vec<&JsonValue>, colors: Option<Vec<Color>>, remainder_color: Option<Color>) -> String { let mut gen = highlight::HighlightGenerator::new_with_colors_and_remainder(colors, remainder_color); gen.write_json_with_highlight( json_object, &mut slices ).expect("Can't fail"); gen.consume() }