Merge pull request #6357 from cloudrac3r/fix-formatted-message-display

Fix formatted_body being parsed as Markdown
This commit is contained in:
Adam Brown 2022-06-27 12:07:18 +01:00 committed by GitHub
commit 1d573e3f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

1
changelog.d/6357.bugfix Normal file
View File

@ -0,0 +1 @@
Fix backslash escapes in formatted messages

View File

@ -30,8 +30,11 @@ import io.noties.markwon.PrecomputedFutureTextSetterCompat
import io.noties.markwon.ext.latex.JLatexMathPlugin import io.noties.markwon.ext.latex.JLatexMathPlugin
import io.noties.markwon.ext.latex.JLatexMathTheme import io.noties.markwon.ext.latex.JLatexMathTheme
import io.noties.markwon.html.HtmlPlugin import io.noties.markwon.html.HtmlPlugin
import io.noties.markwon.inlineparser.HtmlInlineProcessor
import io.noties.markwon.inlineparser.MarkwonInlineParser
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin
import org.commonmark.node.Node import org.commonmark.node.Node
import org.commonmark.parser.Parser
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -63,14 +66,25 @@ class EventHtmlRenderer @Inject constructor(
} }
} }
}) })
.usePlugin(MarkwonInlineParserPlugin.create())
.usePlugin(JLatexMathPlugin.create(44F) { builder -> .usePlugin(JLatexMathPlugin.create(44F) { builder ->
builder.inlinesEnabled(true) builder.inlinesEnabled(true)
builder.theme().inlinePadding(JLatexMathTheme.Padding.symmetric(24, 8)) builder.theme().inlinePadding(JLatexMathTheme.Padding.symmetric(24, 8))
}) })
} else { } else {
builder builder
}.textSetter(PrecomputedFutureTextSetterCompat.create()).build() }
.usePlugin(
MarkwonInlineParserPlugin.create(
MarkwonInlineParser.factoryBuilderNoDefaults().addInlineProcessor(HtmlInlineProcessor())
)
)
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureParser(builder: Parser.Builder) {
builder.enabledBlockTypes(kotlin.collections.emptySet())
}
})
.textSetter(PrecomputedFutureTextSetterCompat.create())
.build()
val plugins: List<MarkwonPlugin> = markwon.plugins val plugins: List<MarkwonPlugin> = markwon.plugins