MCPcopy Create free account
hub / github.com/AI45Lab/Code / split_frontmatter

Function split_frontmatter

core/src/config/agent_dir.rs:373–389  ·  view source on GitHub ↗

Split a leading `---\n…\n---` YAML frontmatter block from the markdown body. Returns `(None, whole)` when there is no frontmatter.

(content: &str)

Source from the content-addressed store, hash-verified

371/// Split a leading `---\n…\n---` YAML frontmatter block from the markdown body.
372/// Returns `(None, whole)` when there is no frontmatter.
373fn 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)]
392struct ScheduleFront {

Callers 3

load_schedulesFunction · 0.85
load_toolsFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by 1