summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-05-20 00:24:37 +0200
committerJonas Smedegaard <dr@jones.dk>2021-05-20 00:49:33 +0200
commitd14e31dba61f9df674a8080d9182151529c68c36 (patch)
tree626fd37d5579742cc54cc67de2be172e2710c3a7
parentb108c8bebbff70fedae6425128619e038fc73352 (diff)
restructure composition of output
-rwxr-xr-xbin/events2md.pl32
1 files changed, 16 insertions, 16 deletions
diff --git a/bin/events2md.pl b/bin/events2md.pl
index 8618b24..71111c3 100755
--- a/bin/events2md.pl
+++ b/bin/events2md.pl
@@ -181,12 +181,11 @@ sub print_event
my $description = unescape( $event->{DESCRIPTION} );
$description =~ s/\n\n[Pp]ris:\s*((?!\n).+)\s*\z//m;
my $price = $1;
+ my @attendees;
if ( $event->{ATTENDEE} ) {
- $description .= " \nMed ";
- $description .= join ' og ',
- map { $_->{CN} || $_->{value} =~ s/^mailto://r }
- @{ $event->{ATTENDEE} };
- $description .= '.';
+ for ( @{ $event->{ATTENDEE} } ) {
+ push @attendees, $_->{'CN'} || $_->{value} =~ s/^mailto://r;
+ }
}
my $location = unescape( $event->{LOCATION} );
my $time_begin = ucfirst( $event->{DTSTART}->strftime('%A') );
@@ -203,22 +202,23 @@ sub print_event
}
}
- $_ = <<"STRING";
-### $time_begin. $summary
-$description
-
-STRING
- $_ .= "**Mødested:** $location \n"
+ $_ = "### $time_begin.";
+ $_ .= " $summary"
+ if $summary;
+ $_ .= "\n$description";
+ $_ .= " \nMed " . join( ' og ', @attendees ) . '.'
+ if @attendees;
+ $_ .= " \n**Mødested:** $location"
if $location;
- $_ .= "**Tid:** ${time_begin}-${time_end}. \n"
+ $_ .= " \n**Tid:** ${time_begin}-${time_end}."
if $time_begin and $time_end;
- $_ .= "**Pris:** $price \n"
+ $_ .= " \n**Pris:** $price"
if $price;
- $_ .= "[Køb billet på Billetto]($attachments{'billetto.dk'}[0]) \n"
+ $_ .= " \n[Køb billet på Billetto]($attachments{'billetto.dk'}[0])"
if $attachments{'billetto.dk'};
- $_ .= "[Læs mere her]($attachments{'byvandring.nu'}[0]) \n"
+ $_ .= " \n[Læs mere her]($attachments{'byvandring.nu'}[0])"
if $attachments{'byvandring.nu'};
- $_ .= "\n---\n\n";
+ $_ .= "\n\n---\n\n";
if ($path) {
$path->append_utf8($_);