[templates] Cleaning up how notes are displayed
All checks were successful
build & deploy / test (push) Successful in 1m43s
build & deploy / deploy (push) Successful in 22s

This commit is contained in:
2026-03-24 16:07:17 -04:00
parent a79cc4c217
commit 5b3e91fdc1
7 changed files with 40 additions and 10 deletions

View File

@ -38,7 +38,7 @@ class TaskLogData(BaseLogData):
"todoist_project_id",
}
def notes_as_str(self) -> str:
def notes_as_str(self, separator: str = " | ") -> str:
"""Return formatted notes with line breaks and no keys"""
labels_str = ""
if self.labels:
@ -60,7 +60,34 @@ class TaskLogData(BaseLogData):
lines += note
if isinstance(note, str):
lines.append(note)
return "\n".join(lines).encode("utf-8").decode("unicode_escape")
return separator.join(lines).encode("utf-8").decode("unicode_escape")
def notes_as_html(self) -> str:
if not self.notes:
return ""
notes = self.notes
if isinstance(notes, str):
notes = [notes]
html_notes = []
for note in notes:
if isinstance(note, dict):
timestamp, note_text = next(iter(note.items()))
note_text = " ".join(note_text.strip().split())
html_notes.append(
f'<div class="sticky-note">{timestamp}: {note_text}</div>'
)
elif isinstance(note, str):
escaped = note.encode("utf-8").decode("unicode_escape")
for line in escaped.split("\n"):
if line.strip():
html_notes.append(f'<div class="sticky-note">{line}</div>')
elif isinstance(note, list):
for item in note:
if isinstance(item, str):
html_notes.append(f'<div class="sticky-note">{item}</div>')
return "".join(html_notes)
class Task(LongPlayScrobblableMixin):