INNER CODE UNIT · Python
_parse_frontmatter
kevinpbuckley/VibeUE · Content/Python/init_unreal.py:30
def _parse_frontmatter(text):
"""Return (description, body) from a markdown file with optional YAML frontmatter."""
if not text.startswith("---"):
return "", text.strip()
close = text.find("\n---", 3)
if close == -1:
return "", text.strip()
frontmatter = text[3:close]
body = text[close + 4:].lstrip("\r\n")
description = ""
for line in frontmatter.splitlines():
stripped = line.strip()
if stripped.startswith("description:"):
description = stripped[len("description:"):].strip().strip('"').strip("'")
break