diff options
author | Jonas Smedegaard <dr@jones.dk> | 2021-05-20 00:24:37 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-08-27 23:39:36 +0200 |
commit | 487dcb5409b13014a5173f1cda3b3667c9929a2b (patch) | |
tree | ae52671522320a384b203e981c807668451367d5 | |
parent | 5d16a8ecc1797be48712fb0752b5ee53bf37fcdd (diff) |
restructure composition of output
-rwxr-xr-x | bin/events2md.pl | 32 |
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($_); |