Split a leading `---\n…\n---` YAML frontmatter block from the markdown body. Returns `(None, whole)` when there is no frontmatter.
(content: &str)
| 371 | /// Split a leading `---\n…\n---` YAML frontmatter block from the markdown body. |
| 372 | /// Returns `(None, whole)` when there is no frontmatter. |
| 373 | fn split_frontmatter(content: &str) -> (Option<String>, String) { |
| 374 | let trimmed = content.trim_start(); |
| 375 | if let Some(rest) = trimmed.strip_prefix("---") { |
| 376 | let rest = rest.trim_start_matches(['\r', '\n']); |
| 377 | // Closing fence: a line that is exactly `---`. |
| 378 | for marker in ["\n---\n", "\n---\r\n", "\n---"] { |
| 379 | if let Some(end) = rest.find(marker) { |
| 380 | let front = rest[..end].to_string(); |
| 381 | let body = rest[end + marker.len()..] |
| 382 | .trim_start_matches(['\r', '\n']) |
| 383 | .to_string(); |
| 384 | return (Some(front), body); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | (None, content.to_string()) |
| 389 | } |
| 390 | |
| 391 | #[derive(serde::Deserialize)] |
| 392 | struct ScheduleFront { |