use of edu.stanford.bmir.protege.web.shared.issues.Mention in project webprotege by protegeproject.
the class CommentRenderer method renderComment.
public String renderComment(String commentBody) {
List<ParsedMention> parsedMentions = mentionParser.parseMentions(commentBody);
StringBuilder rendering = new StringBuilder();
int currentPos = 0;
for (ParsedMention pm : parsedMentions) {
int startIndex = pm.getStartIndex();
int endIndex = pm.getEndIndex();
rendering.append(commentBody.substring(currentPos, startIndex));
Mention mention = pm.getParsedMention();
if (mention.getMentionedUserId().isPresent()) {
rendering.append("<span class=\"wp-comment__user-mention\">");
rendering.append(mention.getMentionedUserId().get().getUserName());
rendering.append("</span>");
} else {
rendering.append(commentBody.substring(startIndex, endIndex));
}
currentPos = endIndex;
}
if (currentPos < commentBody.length()) {
rendering.append(commentBody.substring(currentPos));
}
PegDownProcessor processor = new PegDownProcessor(Extensions.ABBREVIATIONS | Extensions.QUOTES | Extensions.STRIKETHROUGH | Extensions.AUTOLINKS | Extensions.FENCED_CODE_BLOCKS, new PegDownPlugins.Builder().build());
String html = processor.markdownToHtml(rendering.toString(), new LinkRenderer() {
});
return html;
}
Aggregations