Skip to content

Commit 10dd0be

Browse files
initcronclaude
andcommitted
fix: Render markdown bold and code inline in CLI output
Improved markdown rendering in bullet lists for CLI: - **bold text** now renders as bright white bold (not raw **) - `code text` renders as cyan colored text - Clean, professional output without markdown syntax clutter Example output: Before: • **keen_yonath**: alpine/socat After: • keen_yonath: alpine/socat (bold and colored) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b0ff94e commit 10dd0be

1 file changed

Lines changed: 43 additions & 3 deletions

File tree

  • crates/aofctl/src/commands

crates/aofctl/src/commands/run.rs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,23 +971,63 @@ fn try_render_markdown_table(content: &str) -> Option<String> {
971971
}
972972
}
973973

974-
/// Render bullet list with colors
974+
/// Render bullet list with colors and markdown formatting
975975
fn render_bullet_list(content: &str) -> String {
976976
use colored::Colorize;
977977

978978
content.lines()
979979
.map(|line| {
980980
let trimmed = line.trim();
981981
if trimmed.starts_with('*') || trimmed.starts_with('-') || trimmed.starts_with("•") {
982-
format!(" {} {}", "•".bright_cyan(), trimmed[1..].trim())
982+
let text = trimmed[1..].trim();
983+
let formatted = format_inline_markdown_cli(text);
984+
format!(" {} {}", "•".bright_cyan(), formatted)
983985
} else {
984-
line.to_string()
986+
let formatted = format_inline_markdown_cli(line);
987+
formatted
985988
}
986989
})
987990
.collect::<Vec<_>>()
988991
.join("\n")
989992
}
990993

994+
/// Format inline markdown for CLI (bold, code, etc.)
995+
fn format_inline_markdown_cli(text: &str) -> String {
996+
use colored::Colorize;
997+
998+
let mut result = text.to_string();
999+
1000+
// Bold text **text** -> colored bold
1001+
while let Some(start) = result.find("**") {
1002+
if let Some(end) = result[start + 2..].find("**") {
1003+
let before = &result[..start];
1004+
let bold_text = &result[start + 2..start + 2 + end];
1005+
let after = &result[start + 2 + end + 2..];
1006+
// Format bold text
1007+
let formatted_bold = bold_text.to_string().bright_white().bold();
1008+
result = format!("{}{}{}", before, formatted_bold, after);
1009+
} else {
1010+
break;
1011+
}
1012+
}
1013+
1014+
// Inline code `text` -> cyan
1015+
while let Some(start) = result.find('`') {
1016+
if let Some(end) = result[start + 1..].find('`') {
1017+
let before = &result[..start];
1018+
let code_text = &result[start + 1..start + 1 + end];
1019+
let after = &result[start + 1 + end + 1..];
1020+
// Format code text
1021+
let formatted_code = code_text.to_string().cyan();
1022+
result = format!("{}{}{}", before, formatted_code, after);
1023+
} else {
1024+
break;
1025+
}
1026+
}
1027+
1028+
result
1029+
}
1030+
9911031
/// Try to render docker stats output
9921032
fn try_render_docker_stats(content: &str) -> Option<String> {
9931033
use comfy_table::{Table, presets::UTF8_FULL};

0 commit comments

Comments
 (0)