fix: 日报日期属性移到标题下引用行

This commit is contained in:
Benature
2026-11-22 22:26:31 +08:00
parent 2de88ec003
commit f48ae4f809
3 changed files with 16 additions and 7 deletions

View File

@ -1066,7 +1066,10 @@ def summarize_messages(
]
day_context = _day_context(target_day)
if not rows and not calendar_events:
return f"# {target_day.isoformat()} 工作总结({day_context})\n\n本日未收到消息。\n"
return (
f"# {target_day.isoformat()} 工作总结\n\n"
f"> {day_context}\n\n本日未收到消息。\n"
)
messages = [serialize_message(row, tz) for row in rows]
groups: dict[str, list[dict[str, Any]]] = {}
for message in messages:
@ -1278,13 +1281,17 @@ def summarize_messages(
content = sanitize_wikilink_pipes(
drop_casual_content(format_followup_checkboxes(shorten_headings(content)))
)
# Prepend day context to the title
if content.startswith("# "):
content = content.replace(
# Keep day context out of the heading so calendar metadata is easy to hide.
if content.startswith(f"# {target_day.isoformat()}"):
lines = content.splitlines()
lines[0] = re.sub(
rf"^# {re.escape(target_day.isoformat())}([^)]*)",
f"# {target_day.isoformat()}",
f"# {target_day.isoformat()}({day_context})",
1,
lines[0],
)
lines.insert(1, "")
lines.insert(2, f"> {day_context}")
content = "\n".join(lines) + ("\n" if content.endswith("\n") else "")
return content