diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java index fddce3b9e6cd..fc6f7e9e1256 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/service/notifications/MailService.java @@ -8,6 +8,8 @@ import java.util.Locale; import java.util.Set; +import org.commonmark.parser.Parser; +import org.commonmark.renderer.html.HtmlRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -261,6 +263,18 @@ public void sendNotification(Notification notification, User user, Object notifi // posts use a different mechanism for the url context.setVariable(NOTIFICATION_URL, extractNotificationUrl(post, artemisServerUrl.toString())); subject = createAnnouncementText(notificationSubject, locale); + + // Render markdown content of post to html + try { + Parser parser = Parser.builder().build(); + HtmlRenderer renderer = HtmlRenderer.builder().build(); + String postContent = post.getContent(); + String renderedPostContent = renderer.render(parser.parse(postContent)); + post.setContent(renderedPostContent); + } + catch (Exception e) { + // In case something goes wrong, leave content of post as-is + } } else { context.setVariable(NOTIFICATION_URL, extractNotificationUrl(notification, artemisServerUrl.toString()));