HTML formatted text in Google Calendar Event description
Asked Answered
A

6

14

We sync calendar for our clients using Google Calendar API. Event.description has always been in plain text and is supposed to be plain text, right? But recently we started running into cases of HTML formatted text that our code is not prepared to handle.

There is actually a very long thread about new Google apps causing this: https://productforums.google.com/forum/#!topic/calendar/r3OC4cL53NQ

It's actually pretty funny. A Google Cloud team sent me an invitation today and the event description is HTML garbage in my Mac iCal. This is all because Google Calendar apps started writing HTML to the field that is treated as plain text by anyone using Google Calendar API.

Even the original iCalendar standard allowed only plain text as part of an event description. HTML markup, such as font attributes (bold, underline) and layout (<div>, <table>) was not allowed in the text description field.

Antecedence answered 15/3, 2018 at 18:43 Comment(3)
We are not the google calendar team, we're a bunch of volunteers who may have some knowledge about programming against the google calendar APIReseda
You’ll be surprised. Companies like Google, Microsoft, ... instruct their users to file questions in Stackoverflow because their engineers actively monitor certain tags and respond.Antecedence
Well that's not the majority of users. 99% of us are volunteers.Reseda
A
5

I thought I'd chime in here.

Originally, google incorporated the "Internet Calendar Standard" (ICAL -- not iCal, that's mac only), which was an open standard for calendar databases. It began when programmers wanted an alternative to Microsoft's VCAL standard (short for VISUAL CALENDAR STANDARD --a reference to their programming utilities, which natively handled these types of items if the header data was included).

While they were attempting to write something different, they ended up with something very similar, and the two originally worked well together in a one way communication mode. Some programmers got brave and programmed two-way or multi-directional modes that were edit capable from Microsoft Outlook or the other platform that was using ICAL.

The problems they dealt with were figuring out how to format data, since VCAL could use HTML (you could copy from any document you created in Office programs or use a mail merge operation to create many events) and in ICAL you had only plain text; the other problems was how to deal with recurring or repeating events, since Exchange treated them as one piece of data with a modifier that denoted how they were duplicated. Microsoft was focused on memory space, since that was costly when the programming was created, and open source was focused on expedience and portability.

Most of this HAS NOT CHANGED. Google still uses the ICAL standard as its primary guideline on how to do calendars, since it's portable and the programming will be similar across platforms. However, with more people using more powerful systems, with more than enough power to handle some visual formatting, Google has "allowed" HTML to be added in the data fields.

What they have not yet done is set up a section of the API to handle it for you. You have to build your own data handlers for dealing with HTML, and displaying it. In short: YOU HAVE TO PARSE THE HTML FOR YOURSELF.

Many visual platforms DO IN FACT have an HTML implementation. The best practice, then, is to grab just a bit of the text, and find out if there is HTML present in it, parse the HTML if you need to, then display. Another option is to find the HTML, then remove it. There are repositories on GITHUB and in SourceForge that have methods for removing the HTML from text, turning it into PLAIN TEXT.

I have experienced the same confusion, though, admittedly with different overall problems to solve. I've done it for the last 20 years. It was a lot of reading and finding the right people to augment my own capability for a particular issue, but ultimately, the interconnectivity and secure access markets have begun to work together in providing the linkup between platforms.

Early in the Google life cycle, it all had to be done with powershell and WinAMP apache, using javascript to drop information into temporary files that were then picked up by the opposite programming interface. It meant programming watchdogs (applications that checked if there were changes to files etc) into each system, then having each platform check to see if it was the start or the end of the update chain. It was daunting, and clunky, and it was leveraged over internal servers with little power to spare, but it ran.

Eventually, places that dealt with the APIs of either or both would have to buy into large sets of servers to handle the processing loads of different operations, but most of them still stayed limited to small sets. Only one or two moved on to "Bigger and Better Business" structures. Now the big ones are all hybridized, the small ones usually have a single server for internal operations, and are all cloud for their communications. That move was considerably more difficult.

Amphi answered 16/2, 2021 at 23:41 Comment(2)
Wow - neat post ... extremely relevant historic context of the problem, with practical tips how to deal with the HTML. (Not to mention extremely current! :D) How to decide whether a text is (or contains) HTML or not? - Starts with a "<" (and finishes with a ">")? - Contains "/>" or "</"? - Contains &lt; and similar? - Is valid HTML (body content) when checked with a validator? Google have probably implemented their own logic in order to display the text/html correctly within the Calendar ... can't they publish their logic for everybody to use?Antigua
For a post on formatting... this is one long paragraph :)Alika
P
2

On Google's version 3 of the calendar API. In their documentation, it says the following "Description of the event. Can contain HTML. Optional."

Source: https://developers.google.com/calendar/v3/reference/events/insert

Profusion answered 21/3, 2020 at 9:44 Comment(0)
A
2
For what it is worth. I have been able to update the Google Calendar API (Google Events) description field with very basic HTML:

HTML headings <h1> to <h6>

Line Breaks <br>

Line Breaks <br>

Horizontal rule <hr>

I suspect others will work as well (my event js below).

let remarks = '<ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul><br><hr><h2>h2 tag!</h2>'
            let event = {
                "description":
                '<hr> Super limited HTML!: ' + remarks,
                "colorId": colorID,
                "summary": SOtitle,
                "end": {
                    "dateTime": end,
                    "timeZone": $rootScope.app.timezone
                },
                "attendees": attendeesArrray,
                "sendUpdates": "all",

                "start": {
                    "dateTime": start,
                    'timeZone': timezone
      },
  };

enter image description here

Aguish answered 19/7, 2021 at 18:36 Comment(0)
A
0

Yes, the latest update has "Allowed" a few HTML tags. You'll have to conform your HTML from other linked calendars that talk to each other, and most don't have an easy way to do this. For simple text formatting, however, you shouldn't have to worry anymore. For anything beyond that, I suggest the following: Use an attachment. If a message on one server contains HTML, you could collect it to a file attachment and paste a link in the description box pointing to where you would need to edit the information. That way you'd never have to worry about the two talking to each other, so long as your link was active. It would open in the browser. If going to other people, it will be in files contained in the attachments, and you can handle that easily. Otherwise, the only way is to test it out and see how much you can mix it up. I haven't pushed it yet, but I may. I'm just getting back into it a little.

Amphi answered 29/7, 2021 at 3:17 Comment(0)
P
0

Like many regular users, I've been using the Apple iOS calendar app for years to access my Google calendar, and every time I edit a note [here's a new fact: I'm usually seeing it in all-day appointments] in the Google calendar using their web interface, it's been converting everything to HTML. The iOS calendar then displays it verbatim, which is pretty dumb to see on that phone screen, already pretty small to be reading a paragraph of notes. This has been going on for years. What a mess.

I've never tried the Google Calendar API, but it seems like the wrong way for me to be going, as this handshake should be resolved by the Google and/or Apple folks.

I don't really see why leaving plain text alone would be such a bad thing. If a user embeds HTML in a Google calendar note, then sure, leave it that way, but they shouldn't be messing up perfectly readable plain text.

I'll see if I can figure out how to report this to Google, but I'll admit most things have worked so well, I've not needed to know how to do this.

Update: While I was composing the support request to Google, I think I figured out why this is happening, but it's still a problem. I think I copied/pasted a snippet of (bold) formatted text from an email, into the existing plain text in the event note field in my browser. I couldn't see the formatting, but that's probably what triggered Google to convert my otherwise plain text to HTML formatted gibberish. They clearly need a "plain text" checkbox for us, next to the note field in the calendar web interface.

And, of course... Apple also needs to support HTML formatting in their Calendar app's note field. I just left them a bug/request report on this subject.

Paradox answered 22/4, 2023 at 23:38 Comment(0)
P
0

Here's a few things I found out regarding how that HTML is displayed on https://calendar.google.com/

Things that don't work

  • inline styles
  • images (at least I couldn't get them to work)
  • <details>
  • <svg>
  • <iframe>
  • <time>
  • anything interactive (forms/buttons/input/...)

Things that work

  • links
  • lists
  • tables
  • <br>
  • <h1> - <h6>
  • <abbr>
  • <b>
  • <cite> (renders italic)
  • <code>
  • <del>
  • <em> (renders italic)
  • <i>
  • <ins> (renders underscored)
  • <kbd> (renders monospace)
  • <q>
  • <s>
  • <samp> (renders monospace)
  • <var> (renders italic)
  • <small>
  • <strong>
  • <sub>/<sup>
  • <address>
  • <blockquote>
  • <dl>
  • <pre>
Postnatal answered 3/8 at 23:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.