1extern crate lazy_static;
4
5mod codes;
6mod custom;
7mod styling;
8mod templating;
9
10pub use codes::CODES;
11pub use custom::{add_style, delete_styles, resolve_styles, CustomStyleError};
12pub use styling::ColorError;
13pub use templating::{clean_template, colorize_template};
14
15pub fn colorize(content: &str, styles: &[&str]) -> String {
17 let mut header = String::new();
18 let mut footer = String::new();
19
20 for style in styles {
22 let tokens: Vec<&str> = style.split(" ").collect();
24
25 for resolved in custom::resolve_styles(&tokens) {
27 let (open, close) = styling::style_to_ansi(&resolved);
29
30 if open != "" && close != "" {
32 header.push_str(open.as_str());
33 footer.insert_str(0, close.as_str());
34 }
35 }
36 }
37
38 format!("{}{}{}", header, content, footer)
39}