(frontmatter: &str, key: &str)
| 98 | } |
| 99 | |
| 100 | fn parse_frontmatter_value(frontmatter: &str, key: &str) -> Option<String> { |
| 101 | for line in frontmatter.lines() { |
| 102 | let trimmed = line.trim(); |
| 103 | if trimmed.is_empty() || trimmed.starts_with('#') { |
| 104 | continue; |
| 105 | } |
| 106 | if let Some(value) = trimmed.strip_prefix(&format!("{key}:")) { |
| 107 | let value = value.trim(); |
| 108 | if value.len() >= 2 { |
| 109 | if (value.starts_with('"') && value.ends_with('"')) |
| 110 | || (value.starts_with('\'') && value.ends_with('\'')) |
| 111 | { |
| 112 | return Some(value[1..value.len() - 1].to_string()); |
| 113 | } |
| 114 | } |
| 115 | return Some(value.to_string()); |
| 116 | } |
| 117 | } |
| 118 | None |
| 119 | } |
| 120 | |
| 121 | fn parse_skill_file(path: &Path) -> Option<SkillInfo> { |
| 122 | let raw = fs::read_to_string(path).ok()?; |
no test coverage detected