build: garden update 2026-04-18 08:39 — content/sessions/2026-04-18-session.md scripts/garden-session.sh scripts/parse_daily.py
This commit is contained in:
parent
51e4fac4db
commit
5dec7c1436
3 changed files with 126 additions and 31 deletions
44
scripts/parse_daily.py
Executable file
44
scripts/parse_daily.py
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import yaml
|
||||
import json
|
||||
from datetime import date
|
||||
|
||||
class DateEncoder(json.JSONEncoder):
|
||||
def default(self, obj):
|
||||
if isinstance(obj, date):
|
||||
return obj.isoformat()
|
||||
return super().default(obj)
|
||||
|
||||
def parse_daily_note(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
parts = content.split('---')
|
||||
if len(parts) < 3:
|
||||
print("{}", file=sys.stderr)
|
||||
return
|
||||
|
||||
frontmatter = yaml.safe_load(parts[1])
|
||||
body = parts[2].strip()
|
||||
|
||||
# Find the "Work:" section
|
||||
work_section = ""
|
||||
in_work_section = False
|
||||
for line in body.splitlines():
|
||||
if line.strip().lower().startswith('**work:**'):
|
||||
in_work_section = True
|
||||
continue
|
||||
if in_work_section:
|
||||
if line.strip() == "" and work_section:
|
||||
# Break on the first blank line after finding some work items
|
||||
break
|
||||
if line.strip().startswith('- '):
|
||||
work_section += line.strip()[2:] + '\n'
|
||||
|
||||
frontmatter['work'] = work_section.strip()
|
||||
print(json.dumps(frontmatter, cls=DateEncoder))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
parse_daily_note(sys.argv[1])
|
||||
Loading…
Add table
Add a link
Reference in a new issue