Extract description from markdown (first line after # if present)
(content: &str)
| 296 | |
| 297 | /// Extract description from markdown (first line after # if present) |
| 298 | fn extract_description(content: &str) -> Option<String> { |
| 299 | let lines: Vec<&str> = content.lines().collect(); |
| 300 | |
| 301 | for line in lines { |
| 302 | let trimmed = line.trim(); |
| 303 | if trimmed.starts_with('#') { |
| 304 | return Some(trimmed.trim_start_matches('#').trim().to_string()); |
| 305 | } |
| 306 | if !trimmed.is_empty() && !trimmed.starts_with("<!--") { |
| 307 | return Some(format!( |
| 308 | "Command: {}", |
| 309 | trimmed.chars().take(50).collect::<String>() |
| 310 | )); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | None |
| 315 | } |
| 316 | |
| 317 | #[cfg(test)] |
| 318 | mod tests { |
no test coverage detected