(fm: &Map<String, Value>, key: &str)
| 334 | } |
| 335 | |
| 336 | fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> { |
| 337 | match fm.get(key) { |
| 338 | Some(Value::Array(items)) => items |
| 339 | .iter() |
| 340 | .filter_map(|v| v.as_str().map(str::to_string)) |
| 341 | .collect(), |
| 342 | Some(Value::String(s)) if !s.is_empty() => s |
| 343 | .split(',') |
| 344 | .map(|p| p.trim().to_string()) |
| 345 | .filter(|p| !p.is_empty()) |
| 346 | .collect(), |
| 347 | _ => Vec::new(), |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | /// Minimal frontmatter splitter for a full markdown document: |
| 352 | /// `---\n<key: value lines>\n---\n<body>`. Enough for templates and the CLI; |
no test coverage detected