From fc2db80952f1fc1c77c101fb76b529502016329a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 17 Dec 2025 16:31:24 +0800 Subject: Escape special characters in markdown formatting The `md` function now handles backslash escapes for specific characters (*, <, >, `) to allow them to be displayed literally in formatted text. This fixes rendering of help documentation that uses these characters as symbols. --- src/utils/display.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/utils/display.rs') diff --git a/src/utils/display.rs b/src/utils/display.rs index ca1f3b5..4610f4f 100644 --- a/src/utils/display.rs +++ b/src/utils/display.rs @@ -176,6 +176,24 @@ pub fn md(text: impl AsRef) -> String { let chars: Vec = text.chars().collect(); while i < chars.len() { + // Check for escape character \ + if chars[i] == '\\' && i + 1 < chars.len() { + let escaped_char = chars[i + 1]; + // Only escape specific characters + if matches!(escaped_char, '*' | '<' | '>' | '`') { + let mut escaped_text = escaped_char.to_string(); + + // Apply current color stack + for color in color_stack.iter().rev() { + escaped_text = apply_color(&escaped_text, color); + } + + result.push_str(&escaped_text); + i += 2; + continue; + } + } + // Check for color tag start [[color]] if i + 1 < chars.len() && chars[i] == '[' && chars[i + 1] == '[' { let mut j = i + 2; -- cgit