events.pm: output depends on format

This commit is contained in:
Milan
2022-04-22 13:51:59 +02:00
parent 41ae39771b
commit d2d0f66d04

View File

@@ -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) = @_;