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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use PrettyPrinter;
use termwidth;
// TODO: This doesn't syntax highlight code blocks
//
// use textwrap::termwidth;
// use syntect::easy::HighlightLines;
// use syntect::highlighting::{Style, ThemeSet};
// use syntect::parsing::SyntaxSet;
// use syntect::util::as_24_bit_terminal_escaped;
//
// pub fn lines_via_syntect(msg: &String) {
// let lines = if termwidth() > 100 {
// textwrap::wrap(&msg, 60)
// .iter()
// .map(|s| s.to_string())
// .collect::<Vec<String>>()
// } else {
// msg
// .split("\n")
// .map(|s| s.to_string())
// .collect::<Vec<String>>()
// };
//
// let syn_set = SyntaxSet::load_defaults_newlines();
// let theme_set = ThemeSet::load_defaults();
// let syntax = syn_set.find_syntax_by_extension("md").unwrap();
// let mode = dark_light::detect();
// let mut highlighter = HighlightLines::new(
// syntax,
// match mode {
// dark_light::Mode::Default => &theme_set.themes["base16-mocha.dark"],
// dark_light::Mode::Dark => &theme_set.themes["base16-mocha.dark"],
// dark_light::Mode::Light => &theme_set.themes["InspiredGitHub"],
// },
// );
//
// for line in lines {
// let ranges: Vec<(Style, &str)> = highlighter //
// .highlight_line(line, &syn_set)
// .unwrap();
// let escaped = as_24_bit_terminal_escaped(&ranges[..], true);
// print!("{}\n", escaped);
// }
// }