diff -r 9219e2d4117b -r d71bc6db42ef src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Sun Sep 26 14:59:36 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Sat Oct 09 17:46:12 2021 +0200 @@ -30,6 +30,7 @@ import com.vladsch.flexmark.html.HtmlRenderer import com.vladsch.flexmark.parser.Parser import com.vladsch.flexmark.util.data.MutableDataSet +import com.vladsch.flexmark.util.data.SharedDataKeys import de.uapcore.lightpit.entities.* import de.uapcore.lightpit.types.IssueCategory import de.uapcore.lightpit.types.IssueStatus @@ -68,19 +69,30 @@ val version: Version? = null, val component: Component? = null ) : View() { + private val parser: Parser + private val renderer: HtmlRenderer init { val options = MutableDataSet() - .set(Parser.EXTENSIONS, listOf(TablesExtension.create(), StrikethroughExtension.create())) - val parser = Parser.builder(options).build() - val renderer = HtmlRenderer.builder(options).build() - val process = fun(it: String) = renderer.render(parser.parse(it)) + .set(SharedDataKeys.EXTENSIONS, listOf(TablesExtension.create(), StrikethroughExtension.create())) + parser = Parser.builder(options).build() + renderer = HtmlRenderer.builder(options + .set(HtmlRenderer.ESCAPE_HTML, true) + ).build() - issue.description = process(issue.description ?: "") + issue.description = formatMarkdown(issue.description ?: "") for (comment in comments) { - comment.commentFormatted = process(comment.comment) + comment.commentFormatted = formatMarkdown(comment.comment) } } + + private fun formatEmojis(text: String) = text + .replace("(/)", "✅") + .replace("(x)", "❌") + .replace("(!)", "⚡") + + private fun formatMarkdown(text: String) = + renderer.render(parser.parse(formatEmojis(text))) } class IssueEditView(