diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 6c5e4e3..30dcf1c 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -382,28 +382,9 @@ sub modify_results ($$$$) { } #build content - if ( ( defined $params->{template} ) - && ( $params->{template} =~ /\.html/ ) ) - { - if ( defined $result->{content} ) { - if (($result->{content_format}//'') eq 'markdown'){ - $result->{content} = markup::markdown_to_html( $result->{content} ); - }else{ - $result->{content} = markup::fix_line_ends( $result->{content} ); - $result->{content} = markup::creole_to_html( $result->{content} ); - } - $result->{html_content} = $result->{content}; - } - - if ( defined $result->{topic} ) { - if (($result->{content_format}//'') eq 'markdown'){ - $result->{topic} = markup::markdown_to_html( $result->{topic} ); - }else{ - $result->{topic} = markup::fix_line_ends( $result->{topic} ); - $result->{topic} = markup::creole_to_html( $result->{topic} ); - } - $result->{html_topic} = $result->{topic}; - } + if ( ( defined $params->{template} ) && ( $params->{template} =~ /\.html/ ) ) { + $result->{html_content} = events::format($result, 'content') if defined $result->{content}; + $result->{html_topic} = events::format($result, 'topic') if defined $result->{topic}; } #detect if images are in content or topic field @@ -435,6 +416,17 @@ sub modify_results ($$$$) { return $results; } +sub format { + my ($event, $field) = @_; + if (($event->{content_format}//'') eq 'markdown'){ + $event->{$field} = markup::markdown_to_html( $event->{$field} ); + } else { + $event->{$field} = markup::fix_line_ends( $event->{$field} ); + $event->{$field} = markup::creole_to_html( $event->{$field} ); + } + return $event->{$field}; +} + sub add_recurrence_dates { my ($config, $results) = @_;