From d14e31dba61f9df674a8080d9182151529c68c36 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 20 May 2021 00:24:37 +0200 Subject: restructure composition of output --- bin/events2md.pl | 32 ++++++++++++++++---------------- 1 file 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($_); -- cgit v1.2.3