MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / split_frontmatter

Function split_frontmatter

crates/opencode-config/src/loader.rs:748–768  ·  view source on GitHub ↗

Split markdown content into optional YAML frontmatter and body.

(content: &str)

Source from the content-addressed store, hash-verified

746
747/// Split markdown content into optional YAML frontmatter and body.
748fn split_frontmatter(content: &str) -> (Option<String>, String) {
749 let trimmed = content.trim_start();
750 if !trimmed.starts_with("---") {
751 return (None, content.to_string());
752 }
753
754 // Find the closing ---
755 let after_first = &trimmed[3..];
756 if let Some(end_idx) = after_first.find("\n---") {
757 let fm = after_first[..end_idx].trim().to_string();
758 let body_start = end_idx + 4; // skip \n---
759 let body = if body_start < after_first.len() {
760 after_first[body_start..].to_string()
761 } else {
762 String::new()
763 };
764 (Some(fm), body)
765 } else {
766 (None, content.to_string())
767 }
768}
769
770/// Fallback sanitization for invalid YAML frontmatter.
771/// Matches TS `ConfigMarkdown.fallbackSanitization`: if a top-level value

Callers 4

parse_markdown_commandFunction · 0.85
parse_markdown_agentFunction · 0.85

Calls 2

newFunction · 0.85
findMethod · 0.80