from __future__ import annotations from typing import Any import tomlkit Frontmatter = dict[str, Any] def load_frontmatter(s: str) -> dict[str, Any] | None: """Load frontmatter from the contents of an example README.md.""" start = s.find("", start) if end == -1: return None fm = s[start:end].strip() return tomlkit.loads(fm).unwrap()