I've found that the standard output can result in a lot of unwanted whitespace in the description field, so it'd be useful if there was a custom text formatter included to tidy up the output even more.

Comments

DamienMcKenna’s picture

Date iCal v1 included a function date_ical_escape_text() which was used to create pretty barebones output, so replacing it with a field formatter would be useful.

DamienMcKenna’s picture

Some code to play with:

  $text = drupal_render($node_content);
  $text = drupal_html_to_text($text);
  $text = trim($text);
  $text = preg_replace("/\\\b/", "\\\\", $text);
  $text = str_replace(",", "\,", $text);
  $text = str_replace(";", "\;", $text);
  $text = str_replace("\n", "\\n ", $text);
  $text = trim($text);
coredumperror’s picture

I'm not entirely certain what you're asking for, as I've never coded any sort of field formatter. How would one go about starting to make one of those?

DamienMcKenna’s picture

Oh, wait, sorry, I misread the filename - the function is in date_api.

v1 (and possibly v2? I don't know) used to pass the 'description' property through date_ical_escape_text(), which tidied up the text some more and made the text much easier to read. Was there a reason that functionality was dropped?

coredumperror’s picture

I switches from using drupal_html_to_text() to a custom conversion method, because it did things under certain circumstances that clashed horribly with the iCal spec. If you want better control over the whitespace in your iCal output, I'd suggest switching to the iCal Fields row style plugin. That should result in much cleaner output than the auto-converted output from using the iCal Entities plugin.

DamienMcKenna’s picture

I'm already using iCal Fields. The problem is that the HTML output is kinda dirty (redundant DIV wrappers with all content indented), but while browsers don't care about the whitespace it makes the icalendar file look really ugly.

coredumperror’s picture

Hmmm, could you give an example of the bad output you're seeing? Using iCal Fields really shouldn't cause major problems like that, so it might be a bug.

maen’s picture

I can give an example. I opened a new thread before seeing this one, Sorry!

https://www.drupal.org/node/2580981