Parse YAML front matter from a Markdown file.
(md_file: Path)
| 140 | |
| 141 | |
| 142 | def read_front_matter(md_file: Path) -> Optional[dict]: |
| 143 | """Parse YAML front matter from a Markdown file.""" |
| 144 | try: |
| 145 | content = md_file.read_text(encoding="utf-8") |
| 146 | if not content.startswith("---"): |
| 147 | return None |
| 148 | end = content.find("---", 3) |
| 149 | if end == -1: |
| 150 | return None |
| 151 | fm_str = content[3:end].strip() |
| 152 | return yaml.safe_load(fm_str) |
| 153 | except Exception: |
| 154 | return None |
| 155 | |
| 156 | |
| 157 | def get_doc_entries(data_dir: Path, section_key: str) -> List[dict]: |
no outgoing calls
no test coverage detected