changed colors as per Jörn's suggestion. (#2200)

* changed colors as per Jörn's suggestion.

* cleaned up old comments
This commit is contained in:
Darren Schroeder 2020-07-17 15:02:54 -05:00 committed by GitHub
parent 6497421615
commit 7b02604e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,7 +184,6 @@ async fn to_html(
)))
}
// fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, &'static str)>, is_dark: bool) {
fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_dark: bool) {
let text_color = if is_dark {
"white".to_string()
@ -208,7 +207,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
1,
(
// Bold Black
// r"(?P<bb>\[1;30m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bb>\[1;30m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
format!(
r"<span style='color:{};font-weight:bold;'>$word</span>",
@ -220,7 +218,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
2,
(
// Bold Red
// r"(?P<br>\[1;31m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<br>\[1;31m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:red;font-weight:bold;'>$word</span>".to_string(),
),
@ -229,7 +226,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
3,
(
// Bold Green
// r"(?P<bg>\[1;32m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bg>\[1;32m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:green;font-weight:bold;'>$word</span>".to_string(),
),
@ -238,16 +234,14 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
4,
(
// Bold Yellow
// r"(?P<by>\[1;33m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<by>\[1;33m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:yellow;font-weight:bold;'>$word</span>".to_string(),
r"<span style='color:#717100;font-weight:bold;'>$word</span>".to_string(),
),
);
hash.insert(
5,
(
// Bold Blue
// r"(?P<bu>\[1;34m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bu>\[1;34m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:blue;font-weight:bold;'>$word</span>".to_string(),
),
@ -256,18 +250,16 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
6,
(
// Bold Magenta
// r"(?P<bm>\[1;35m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bm>\[1;35m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:magenta;font-weight:bold;'>$word</span>".to_string(),
r"<span style='color:#c800c8;font-weight:bold;'>$word</span>".to_string(),
),
);
hash.insert(
7,
(
// Bold Cyan
// r"(?P<bc>\[1;36m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bc>\[1;36m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:cyan;font-weight:bold;'>$word</span>".to_string(),
r"<span style='color:#037979;font-weight:bold;'>$word</span>".to_string(),
),
);
hash.insert(
@ -276,7 +268,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
// Bold White
// Let's change this to black since the html background
// is white. White on white = no bueno.
// r"(?P<bw>\[1;37m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<bw>\[1;37m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
format!(
r"<span style='color:{};font-weight:bold;'>$word</span>",
@ -289,7 +280,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
9,
(
// Black
// r"(?P<b>\[30m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<b>\[30m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
format!(r"<span style='color:{};'>$word</span>", text_color),
),
@ -298,7 +288,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
10,
(
// Red
// r"(?P<r>\[31m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<r>\[31m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:red;'>$word</span>".to_string(),
),
@ -307,7 +296,6 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
11,
(
// Green
// r"(?P<g>\[32m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<g>\[32m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:green;'>$word</span>".to_string(),
),
@ -316,16 +304,14 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
12,
(
// Yellow
// r"(?P<y>\[33m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<y>\[33m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:yellow;'>$word</span>".to_string(),
r"<span style='color:#717100;'>$word</span>".to_string(),
),
);
hash.insert(
13,
(
// Blue
// r"(?P<u>\[34m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<u>\[34m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:blue;'>$word</span>".to_string(),
),
@ -334,18 +320,16 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
14,
(
// Magenta
// r"(?P<m>\[35m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<m>\[35m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:magenta;'>$word</span>".to_string(),
r"<span style='color:#c800c8;'>$word</span>".to_string(),
),
);
hash.insert(
15,
(
// Cyan
// r"(?P<c>\[36m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<c>\[36m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
r"<span style='color:cyan;'>$word</span>".to_string(),
r"<span style='color:#037979;'>$word</span>".to_string(),
),
);
hash.insert(
@ -354,14 +338,12 @@ fn setup_html_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>, is_
// White
// Let's change this to black since the html background
// is white. White on white = no bueno.
// r"(?P<w>\[37m)(?P<word>[A-Za-z0-9\-'!/_~ &;|=\+\*\.#%:\]$`\(\)]+)",
r"(?P<w>\[37m)(?P<word>[[:alnum:][:space:][:punct:]]*)",
format!(r"<span style='color:{};'>$word</span>", text_color),
),
);
}
// fn setup_no_color_regexes(hash: &mut HashMap<u32, (&'static str, &'static str)>, is_dark: bool) {
fn setup_no_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>) {
// We can just use one regex here because we're just removing ansi sequences
// and not replacing them with html colors.
@ -375,7 +357,6 @@ fn setup_no_color_regexes(hash: &mut HashMap<u32, (&'static str, String)>) {
);
}
// fn run_regexes(hash: &HashMap<u32, (&'static str, &'static str)>, contents: &str) -> String {
fn run_regexes(hash: &HashMap<u32, (&'static str, String)>, contents: &str) -> String {
let mut working_string = contents.to_owned();
let hash_count: u32 = hash.len() as u32;
@ -383,7 +364,6 @@ fn run_regexes(hash: &HashMap<u32, (&'static str, String)>, contents: &str) -> S
let value = hash.get(&n).expect("error getting hash at index");
//println!("{},{}", value.0, value.1);
let re = Regex::new(value.0).expect("problem with color regex");
// let replace = value.1.to_owned();
let after = re.replace_all(&working_string, &value.1[..]).to_string();
working_string = after.clone();
}
@ -406,7 +386,7 @@ mod tests {
fn test_cd_html_color_flag_dark_false() {
let mut hm: HashMap<u32, (&str, String)> = HashMap::new();
let cd_help = r"<html><style>body { background-color:white;color:black; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; cd dirname<br><br> Change to your home directory<br> &gt; cd<br><br> Change to your home directory (alternate version)<br> &gt; cd ~<br><br> Change to the previous directory<br> &gt; cd -<br><br></body></html>".to_string();
let cd_help_expected_result = r"<html><style>body { background-color:white;color:black; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; <span style='color:cyan;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:cyan;'>dirname<span style='color:black;font-weight:normal;'><br><br> Change to your home directory<br> &gt; </span><span style='color:cyan;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'><br><br> Change to your home directory (alternate version)<br> &gt; </span></span><span style='color:cyan;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:cyan;'>~<span style='color:black;font-weight:normal;'><br><br> Change to the previous directory<br> &gt; </span><span style='color:cyan;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:cyan;'>-<span style='color:black;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let cd_help_expected_result = r"<html><style>body { background-color:white;color:black; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; <span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#037979;'>dirname<span style='color:black;font-weight:normal;'><br><br> Change to your home directory<br> &gt; </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'><br><br> Change to your home directory (alternate version)<br> &gt; </span></span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#037979;'>~<span style='color:black;font-weight:normal;'><br><br> Change to the previous directory<br> &gt; </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#037979;'>-<span style='color:black;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let is_dark = false;
setup_html_color_regexes(&mut hm, is_dark);
assert_eq!(cd_help_expected_result, run_regexes(&hm, &cd_help));
@ -416,7 +396,7 @@ mod tests {
fn test_cd_html_color_flag_dark_true() {
let mut hm: HashMap<u32, (&str, String)> = HashMap::new();
let cd_help = r"<html><style>body { background-color:black;color:white; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; cd dirname<br><br> Change to your home directory<br> &gt; cd<br><br> Change to your home directory (alternate version)<br> &gt; cd ~<br><br> Change to the previous directory<br> &gt; cd -<br><br></body></html>".to_string();
let cd_help_expected_result = r"<html><style>body { background-color:black;color:white; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; <span style='color:cyan;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:cyan;'>dirname<span style='color:white;font-weight:normal;'><br><br> Change to your home directory<br> &gt; </span><span style='color:cyan;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'><br><br> Change to your home directory (alternate version)<br> &gt; </span></span><span style='color:cyan;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:cyan;'>~<span style='color:white;font-weight:normal;'><br><br> Change to the previous directory<br> &gt; </span><span style='color:cyan;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:cyan;'>-<span style='color:white;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let cd_help_expected_result = r"<html><style>body { background-color:black;color:white; }</style><body>Change to a new path.<br><br>Usage:<br> &gt; cd (directory) {flags} <br><br>Parameters:<br> (directory) the directory to change to<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> Change to a new directory called &#x27;dirname&#x27;<br> &gt; <span style='color:#037979;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#037979;'>dirname<span style='color:white;font-weight:normal;'><br><br> Change to your home directory<br> &gt; </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'><br><br> Change to your home directory (alternate version)<br> &gt; </span></span><span style='color:#037979;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#037979;'>~<span style='color:white;font-weight:normal;'><br><br> Change to the previous directory<br> &gt; </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#037979;'>-<span style='color:white;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let is_dark = true;
setup_html_color_regexes(&mut hm, is_dark);
assert_eq!(cd_help_expected_result, run_regexes(&hm, &cd_help));
@ -435,7 +415,7 @@ mod tests {
fn test_html_color_where_flag_dark_true() {
let mut hm: HashMap<u32, (&str, String)> = HashMap::new();
let where_help = r"<html><style>body { background-color:black;color:white; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; ls | where size &gt; 2kb<br><br> List only the files in the current directory<br> &gt; ls | where type == File<br><br> List all files with names that contain &quot;Car&quot;<br> &gt; ls | where name =~ &quot;Car&quot;<br><br> List all files that were modified in the last two months<br> &gt; ls | where modified &lt;= 2M<br><br></body></html>".to_string();
let where_help_exptected_results = r"<html><style>body { background-color:black;color:white; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; <span style='color:cyan;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>size<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;'>&gt;<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:magenta;font-weight:bold;'>2<span style='color:white;font-weight:normal;'></span></span><span style='color:cyan;font-weight:bold;'>kb<span style='color:white;font-weight:normal;'><br><br> List only the files in the current directory<br> &gt; </span></span><span style='color:cyan;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>type<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;'>==<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:green;'>File<span style='color:white;font-weight:normal;'><br><br> List all files with names that contain &quot;Car&quot;<br> &gt; </span><span style='color:cyan;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>name<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;'>=~<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:green;'>&quot;Car&quot;<span style='color:white;font-weight:normal;'><br><br> List all files that were modified in the last two months<br> &gt; </span><span style='color:cyan;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>modified<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:yellow;'>&lt;=<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:magenta;font-weight:bold;'>2<span style='color:white;font-weight:normal;'></span></span><span style='color:cyan;font-weight:bold;'>M<span style='color:white;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let where_help_exptected_results = r"<html><style>body { background-color:black;color:white; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; <span style='color:#037979;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>size<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;'>&gt;<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#c800c8;font-weight:bold;'>2<span style='color:white;font-weight:normal;'></span></span><span style='color:#037979;font-weight:bold;'>kb<span style='color:white;font-weight:normal;'><br><br> List only the files in the current directory<br> &gt; </span></span><span style='color:#037979;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>type<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;'>==<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:green;'>File<span style='color:white;font-weight:normal;'><br><br> List all files with names that contain &quot;Car&quot;<br> &gt; </span><span style='color:#037979;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>name<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;'>=~<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:green;'>&quot;Car&quot;<span style='color:white;font-weight:normal;'><br><br> List all files that were modified in the last two months<br> &gt; </span><span style='color:#037979;font-weight:bold;'>ls<span style='color:white;font-weight:normal;'></span></span></span></span><span style='color:white;'> | <span style='color:white;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>modified<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#717100;'>&lt;=<span style='color:white;font-weight:normal;'></span></span></span><span style='color:white;'> <span style='color:white;font-weight:normal;'></span><span style='color:#c800c8;font-weight:bold;'>2<span style='color:white;font-weight:normal;'></span></span><span style='color:#037979;font-weight:bold;'>M<span style='color:white;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let is_dark = true;
setup_html_color_regexes(&mut hm, is_dark);
assert_eq!(where_help_exptected_results, run_regexes(&hm, &where_help));
@ -445,7 +425,7 @@ mod tests {
fn test_html_color_where_flag_dark_false() {
let mut hm: HashMap<u32, (&str, String)> = HashMap::new();
let where_help = r"<html><style>body { background-color:white;color:black; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; ls | where size &gt; 2kb<br><br> List only the files in the current directory<br> &gt; ls | where type == File<br><br> List all files with names that contain &quot;Car&quot;<br> &gt; ls | where name =~ &quot;Car&quot;<br><br> List all files that were modified in the last two months<br> &gt; ls | where modified &lt;= 2M<br><br></body></html>".to_string();
let where_help_exptected_results = r"<html><style>body { background-color:white;color:black; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; <span style='color:cyan;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>size<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;'>&gt;<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:magenta;font-weight:bold;'>2<span style='color:black;font-weight:normal;'></span></span><span style='color:cyan;font-weight:bold;'>kb<span style='color:black;font-weight:normal;'><br><br> List only the files in the current directory<br> &gt; </span></span><span style='color:cyan;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>type<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;'>==<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:green;'>File<span style='color:black;font-weight:normal;'><br><br> List all files with names that contain &quot;Car&quot;<br> &gt; </span><span style='color:cyan;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>name<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;'>=~<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:green;'>&quot;Car&quot;<span style='color:black;font-weight:normal;'><br><br> List all files that were modified in the last two months<br> &gt; </span><span style='color:cyan;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:cyan;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;font-weight:bold;'>modified<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:yellow;'>&lt;=<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:magenta;font-weight:bold;'>2<span style='color:black;font-weight:normal;'></span></span><span style='color:cyan;font-weight:bold;'>M<span style='color:black;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let where_help_exptected_results = r"<html><style>body { background-color:white;color:black; }</style><body>Filter table to match the condition.<br><br>Usage:<br> &gt; where &lt;condition&gt; {flags} <br><br>Parameters:<br> &lt;condition&gt; the condition that must match<br><br>Flags:<br> -h, --help: Display this help message<br><br>Examples:<br> List all files in the current directory with sizes greater than 2kb<br> &gt; <span style='color:#037979;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>size<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;'>&gt;<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#c800c8;font-weight:bold;'>2<span style='color:black;font-weight:normal;'></span></span><span style='color:#037979;font-weight:bold;'>kb<span style='color:black;font-weight:normal;'><br><br> List only the files in the current directory<br> &gt; </span></span><span style='color:#037979;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>type<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;'>==<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:green;'>File<span style='color:black;font-weight:normal;'><br><br> List all files with names that contain &quot;Car&quot;<br> &gt; </span><span style='color:#037979;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>name<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;'>=~<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:green;'>&quot;Car&quot;<span style='color:black;font-weight:normal;'><br><br> List all files that were modified in the last two months<br> &gt; </span><span style='color:#037979;font-weight:bold;'>ls<span style='color:black;font-weight:normal;'></span></span></span></span><span style='color:black;'> | <span style='color:black;font-weight:normal;'></span><span style='color:#037979;font-weight:bold;'>where<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;font-weight:bold;'>modified<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#717100;'>&lt;=<span style='color:black;font-weight:normal;'></span></span></span><span style='color:black;'> <span style='color:black;font-weight:normal;'></span><span style='color:#c800c8;font-weight:bold;'>2<span style='color:black;font-weight:normal;'></span></span><span style='color:#037979;font-weight:bold;'>M<span style='color:black;font-weight:normal;'><br><br></body></html></span></span></span>".to_string();
let is_dark = false;
setup_html_color_regexes(&mut hm, is_dark);
assert_eq!(where_help_exptected_results, run_regexes(&hm, &where_help));