diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index db23eb8c1..1a0f22f07 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -39,6 +39,10 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l ## Fixed - Fixed `PUT /api/tasks/:id` ignoring empty arrays for `contexts` and `blockedBy`: sending `{"contexts": []}` or `{"blockedBy": []}` now clears the corresponding frontmatter field instead of silently leaving the previous value in place. The deletion pass previously fired only on a literal `undefined`, which JSON cannot express, so HTTP clients had no way to clear these fields. Thanks to @tgrosinger for the contribution. +- (#2193) Google Calendar event descriptions written with formatting now read as + plain text in event details, copied text, and generated notes, instead of + showing raw HTML tags. Paragraph breaks, list structure, and link addresses are + kept. Thanks to @martin-forge for the contribution. - (#2192) Agenda and list cards for Google and Microsoft calendar events now show the name of the calendar the event belongs to, instead of the generic "Calendar" label. Thanks to @martin-forge for the contribution. diff --git a/src/services/GoogleCalendarService.ts b/src/services/GoogleCalendarService.ts index 68ab065a5..c8566f6fa 100644 --- a/src/services/GoogleCalendarService.ts +++ b/src/services/GoogleCalendarService.ts @@ -16,6 +16,7 @@ import { validateCalendarId, validateEventId, validateRequired } from "./validat import { CalendarProvider, ProviderCalendar } from "./CalendarProvider"; import { createTaskNotesLogger } from "../utils/tasknotesLogger"; import { publishUserNotice } from "../core/userNotices"; +import { normalizeCalendarDescription } from "../utils/calendarDescription"; const tasknotesLogger = createTaskNotesLogger({ tag: "Services/GoogleCalendarService" }); @@ -499,7 +500,7 @@ export class GoogleCalendarService extends CalendarProvider { id: `google-${calendarId}-${googleEvent.id}`, subscriptionId: `google-${calendarId}`, title: googleEvent.summary || "Untitled Event", - description: googleEvent.description, + description: normalizeCalendarDescription(googleEvent.description), start: start, end: end, allDay: allDay, diff --git a/src/utils/calendarDescription.ts b/src/utils/calendarDescription.ts new file mode 100644 index 000000000..7fc07320e --- /dev/null +++ b/src/utils/calendarDescription.ts @@ -0,0 +1,259 @@ +import { sanitizeHTMLToDom } from "obsidian"; + +/** + * Plain-text normalization for calendar event descriptions. + * + * The Google Calendar API documents the event `description` field as one that + * "can contain HTML". Google Calendar and third-party integrations therefore + * store markup such as `

`, `
`, `