1
votes

My script gets calendar events for a range of dates and puts them in a Google Sheet. Then I can "print" the sheet to a PDF and send to the club members. Club members need to book in to events by email. I tried to put "mailto" links in the calendar, but they were not clickable in the PDF, so I stopped doing that, and listed the email addresses as plain text. Now with the new Google Calendar, all email addresses put into Description fields appear as hypertext links. ("Inspect Element" shows things like

<a href="mailto:person@domain" target="_blank">person@domain</a> )

Some of these come through into the spreadsheet as hypertext links (a href="mailto: and so on), some just as the bare email addresses. My script gets the calendar entries with

var events = cal.getEvents
    (new Date(StartMonth + firstDay + ", " + StartYear + " 00:00:00"),
    new Date(  EndMonth +  lastDay + ", " +   EndYear + " 23:59:59"));

and I get the Description out of the "events" array with

events[i].getDescription()

Do you know if a recent change to the type of the Description field of Google Calendar entries could be causing the problem? Are there options to getDescription that could convert HTML to plain text? Or, better still, is there a way to make clickable links in the PDF produced from the Google Sheet? Thanks, Jim

1

1 Answers

2
votes

Do you know if a recent change to the type of the Description field of Google Calendar entries could be causing the problem?

This is due to the update to Google Calendar, initially released Oct. 2017, but which has been rolling out over the past couple months. Google added a text formatting feature (lists, bold, italics, links) to the event description field of the updated version. They are now pushing html tags through their calendar feeds. The update is causing all sorts of problems.

Are there options to getDescription that could convert HTML to plain text?

Yes, but destructively. For the bare minimum, you could look into removing the html tags in javascript. You will lose paragraphs and line breaks this way. Another option is to use a library that can remove tags while preserving some of the plain-text/whitespace formatting, such as textversionjs