(fm: &Map<String, Value>, key: &str)
| 278 | } |
| 279 | |
| 280 | fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> { |
| 281 | match fm.get(key) { |
| 282 | Some(Value::Array(items)) => items |
| 283 | .iter() |
| 284 | .filter_map(|v| v.as_str().map(str::to_string)) |
| 285 | .collect(), |
| 286 | Some(Value::String(s)) if !s.is_empty() => s |
| 287 | .split(',') |
| 288 | .map(|p| p.trim().to_string()) |
| 289 | .filter(|p| !p.is_empty()) |
| 290 | .collect(), |
| 291 | _ => Vec::new(), |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | /// Minimal frontmatter splitter for a full markdown document: |
| 296 | /// `---\n<key: value lines>\n---\n<body>`. Enough for templates and the CLI; |
no test coverage detected