Split YAML frontmatter from markdown body.
(content: str)
| 182 | |
| 183 | |
| 184 | def _split_frontmatter(content: str) -> tuple[dict, str]: |
| 185 | """Split YAML frontmatter from markdown body.""" |
| 186 | if not content.startswith("---"): |
| 187 | return {}, content |
| 188 | |
| 189 | parts = content.split("---", 2) |
| 190 | if len(parts) < 3: |
| 191 | return {}, content |
| 192 | |
| 193 | try: |
| 194 | frontmatter = yaml.safe_load(parts[1]) or {} |
| 195 | except yaml.YAMLError: |
| 196 | frontmatter = {} |
| 197 | |
| 198 | return frontmatter, parts[2] |
no outgoing calls
no test coverage detected