Spaces:
Runtime error
Runtime error
File size: 503 Bytes
aaef24a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | """Utility functions for working with marimo notebooks."""
import re
from pathlib import Path
def get_notebook_title(path: Path) -> str | None:
"""Return the first H1 Markdown heading in a marimo notebook, or None."""
text = path.read_text(encoding="utf-8")
for match in re.finditer(r'mo\.md\(r?f?"""(.*?)"""', text, re.DOTALL):
for line in match.group(1).splitlines():
if line.strip().startswith("# "):
return line.strip()[2:].strip()
return None
|