[templates] Cleaning up how notes are displayed
This commit is contained in:
@ -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):
|
||||
|
||||
Reference in New Issue
Block a user