MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _extract_frontmatter

Function _extract_frontmatter

deployments/desktop/shared/agents.py:501–522  ·  view source on GitHub ↗
(raw: str)

Source from the content-addressed store, hash-verified

499
500
501def _extract_frontmatter(raw: str) -> Tuple[Dict[str, Any], str]:
502 if not raw.startswith("---"):
503 return {}, raw
504 lines = raw.splitlines()
505 if not lines or lines[0].strip() != "---":
506 return {}, raw
507 end_index = None
508 for index in range(1, len(lines)):
509 if lines[index].strip() == "---":
510 end_index = index
511 break
512 if end_index is None:
513 return {}, raw
514 frontmatter_text = "\n".join(lines[1:end_index]).strip()
515 body = "\n".join(lines[end_index + 1 :]).lstrip()
516 if not frontmatter_text:
517 return {}, body
518 try:
519 parsed = yaml.safe_load(frontmatter_text) or {}
520 except yaml.YAMLError:
521 parsed = {}
522 return parsed if isinstance(parsed, dict) else {}, body
523
524
525def _report_title(body: str, path: Path) -> str:

Callers 2

_report_recordFunction · 0.85
_backfill_docs_to_wikiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected