Skip to content

Commit

Permalink
Added syntax highlighting for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 27, 2020
1 parent 24a72ea commit 530f45f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,11 @@ impl Highlighter for LineHighlighter {
let mut coloured = line.to_string();

let reg = Regex::new(
r"(?x)
r#"(?x)
(?P<identifier>[$A-z_]+[$A-z_0-9]*) |
(?P<op>[+\-/*%~^!&|=<>,.;:])",
(?P<string_double_quote>"([^"\\]|\\.)*") |
(?P<string_single_quote>'([^'\\]|\\.)*') |
(?P<op>[+\-/*%~^!&|=<>;:])"#,
)
.unwrap();

Expand All @@ -362,8 +364,12 @@ impl Highlighter for LineHighlighter {
}
_ => cap.as_str().to_string(),
}
} else if let Some(cap) = caps.name("op") {
} else if let Some(cap) = caps.name("string_double_quote") {
cap.as_str().green().to_string()
} else if let Some(cap) = caps.name("string_single_quote") {
cap.as_str().green().to_string()
} else if let Some(cap) = caps.name("op") {
cap.as_str().truecolor(214, 95, 26).to_string()
} else {
caps[0].to_string()
}
Expand Down

0 comments on commit 530f45f

Please sign in to comment.