from __future__ import annotations

import yaml


class DocsFrontmatterParser:
    def split(self, content: str) -> tuple[dict, str]:
        if not content.startswith("---\n"):
            return {}, content
        parts = content.split("---", 2)
        if len(parts) < 3:
            return {}, content
        _, raw, body = parts
        payload = yaml.safe_load(raw) or {}
        return payload if isinstance(payload, dict) else {}, body.strip()
