(bdfd5f2) Apply color guidelines to codebase
This commit is contained in:
+23
-13
@@ -172,7 +172,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
if line.starts_with("## ") {
|
||||
current_section = line;
|
||||
let section_name = &line[3..];
|
||||
result.push_str(&format!("\x1b[33m{}\x1b[0m", section_name));
|
||||
result.push_str(&color_text(section_name, "orange"));
|
||||
result.push('\n');
|
||||
result.push_str(&"─".repeat(line.len()));
|
||||
result.push('\n');
|
||||
@@ -183,7 +183,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
// First line is the title header - color it in green
|
||||
if line.starts_with("# ") && current_section.is_empty() {
|
||||
let header = &line[2..]; // Remove "# "
|
||||
result.push_str(&format!("\x1b[32m{}\x1b[0m", header));
|
||||
result.push_str(&color_text(header, "green"));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
|
||||
// Acceptance Criteria checkboxes
|
||||
if line.starts_with("- [ ]") {
|
||||
result.push_str("\x1b[90m- [ ]\x1b[0m");
|
||||
result.push_str(&color_text("- [ ]", "grey"));
|
||||
result.push_str(&line[5..]);
|
||||
result.push('\n');
|
||||
continue;
|
||||
@@ -218,9 +218,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
let link_start = start + end_bracket + 1;
|
||||
if let Some(end) = line[link_start..].find(']') {
|
||||
let absolute_end = link_start + end + 1;
|
||||
result.push_str("\x1b[36m");
|
||||
result.push_str(&line[start..absolute_end]);
|
||||
result.push_str("\x1b[0m");
|
||||
result.push_str(&color_text(&line[start..absolute_end], "cyan"));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -250,7 +248,7 @@ pub fn colorize_ordered(line: &str) -> String {
|
||||
// still scanning digits
|
||||
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
||||
let number = &line[..i + 1];
|
||||
result.push_str(&format!("\x1b[36m{}\x1b[0m", number));
|
||||
result.push_str(&color_text(number, "cyan"));
|
||||
result.push_str(&line[i + 1..]);
|
||||
return result;
|
||||
} else {
|
||||
@@ -282,13 +280,25 @@ pub fn colorize_metadata(line: &str) -> String {
|
||||
let field_name = &content[after_open..after_open + close_pos];
|
||||
let after_field = &content[after_open + close_pos + 2..];
|
||||
|
||||
let colored_field = color_text(field_name, "red");
|
||||
let value_text = after_field.strip_prefix(": ").map(|s| s.trim()).unwrap_or(after_field);
|
||||
let after_field_colored = if is_unknown_value(value_text) {
|
||||
color_text(after_field, "grey")
|
||||
} else {
|
||||
after_field.to_string()
|
||||
};
|
||||
|
||||
format!(
|
||||
"{}{}{}{}",
|
||||
"{}{}{}",
|
||||
&content[..open_pos],
|
||||
"\x1b[31m",
|
||||
field_name,
|
||||
"\x1b[0m"
|
||||
) + after_field
|
||||
colored_field,
|
||||
after_field_colored
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_unknown_value(value: &str) -> bool {
|
||||
let trimmed = value.trim();
|
||||
trimmed == "_None_" || trimmed == "_Not set_" || trimmed == "-None-" || trimmed == "-Not set-"
|
||||
}
|
||||
|
||||
pub fn colorize_line(line: &str) -> String {
|
||||
@@ -311,7 +321,7 @@ pub fn colorize_line(line: &str) -> String {
|
||||
}
|
||||
|
||||
let bold_text: String = chars[start..end].iter().collect();
|
||||
result.push_str(&format!("\x1b[1;35m{}\x1b[0m", bold_text));
|
||||
result.push_str(&color_text(&bold_text, "magenta"));
|
||||
i = end + 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user