(raw: str)
| 499 | |
| 500 | |
| 501 | def _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 | |
| 525 | def _report_title(body: str, path: Path) -> str: |
no outgoing calls
no test coverage detected