Skip to content

Commit

Permalink
Fix markdown render
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablosanqt committed Oct 18, 2024
1 parent b52e25e commit 02d0290
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down

0 comments on commit 02d0290

Please sign in to comment.