Parse index.md into a list of entry dicts.
()
| 68 | # --------------------------------------------------------------------------- |
| 69 | |
| 70 | def _load_index() -> list[dict]: |
| 71 | """Parse index.md into a list of entry dicts.""" |
| 72 | if not _INDEX_FILE.exists(): |
| 73 | return [] |
| 74 | entries = [] |
| 75 | for line in _INDEX_FILE.read_text().splitlines(): |
| 76 | # Expected table row: | [[slug]] | category | summary | date | |
| 77 | if line.startswith("| [["): |
| 78 | parts = [p.strip() for p in line.split("|") if p.strip()] |
| 79 | if len(parts) >= 3: |
| 80 | link = parts[0] # [[slug]] |
| 81 | category = parts[1] if len(parts) > 1 else "" |
| 82 | summary = parts[2] if len(parts) > 2 else "" |
| 83 | date = parts[3] if len(parts) > 3 else "" |
| 84 | slug = re.sub(r"\[\[|\]\]", "", link) |
| 85 | entries.append({ |
| 86 | "slug": slug, |
| 87 | "category": category, |
| 88 | "summary": summary, |
| 89 | "date": date, |
| 90 | }) |
| 91 | return entries |
| 92 | |
| 93 | |
| 94 | def _save_index(entries: list[dict]) -> None: |
no outgoing calls
no test coverage detected