(fm: &Map<String, Value>, key: &str)
| 261 | } |
| 262 | |
| 263 | fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> { |
| 264 | match fm.get(key) { |
| 265 | Some(Value::Array(items)) => items |
| 266 | .iter() |
| 267 | .filter_map(|v| v.as_str().map(str::to_string)) |
| 268 | .collect(), |
| 269 | Some(Value::String(s)) if !s.is_empty() => s |
| 270 | .split(',') |
| 271 | .map(|p| p.trim().to_string()) |
| 272 | .filter(|p| !p.is_empty()) |
| 273 | .collect(), |
| 274 | _ => Vec::new(), |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /// Minimal frontmatter splitter for a full markdown document: |
| 279 | /// `---\n<key: value lines>\n---\n<body>`. Enough for templates and the CLI; |
no test coverage detected