(frontmatter: dict, body: str)
| 517 | |
| 518 | |
| 519 | def dump_md_frontmatter(frontmatter: dict, body: str) -> str: |
| 520 | if yaml is None: |
| 521 | raise RuntimeError("PyYAML is required to write Markdown frontmatter") |
| 522 | fm_text = yaml.safe_dump(frontmatter, sort_keys=False, allow_unicode=True) |
| 523 | body_to_write = body |
| 524 | if body_to_write.startswith("\n"): |
| 525 | body_to_write = body_to_write[1:] |
| 526 | return "---\n" + fm_text + "---\n" + body_to_write |
| 527 | |
| 528 | |
| 529 | def read_ipynb_meta(path: Path) -> tuple[Any, dict, bool]: |