mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-28 22:18:46 +03:00
Fix formatted_body being parsed as Markdown
Background: Clients write Markdown and convert it to HTML before sending the event. All events are formatted as HTML. However, if an HTML formatted event happened to include markdown characters, Element Android would incorrectly render that markdown. For example, an event with formatted_body: "*test*" should be displayed as literally *test* with no effects, but Element Android incorrectly displayed it as test in italics. This commit fixes this behaviour, making Element Android not parse Markdown in HTML messages. From the perspective of most users it will appear that backslash escapes now work properly (even though this wasn't the real issue).
This commit is contained in:
parent
41431cd1d2
commit
592f890fac
2 changed files with 22 additions and 2 deletions
1
changelog.d/6357.bugfix
Normal file
1
changelog.d/6357.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix backslash escapes in formatted messages
|
|
@ -26,12 +26,17 @@ import im.vector.app.features.settings.VectorPreferences
|
|||
import io.noties.markwon.AbstractMarkwonPlugin
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.MarkwonPlugin
|
||||
import io.noties.markwon.MarkwonPlugin.Registry
|
||||
import io.noties.markwon.PrecomputedFutureTextSetterCompat
|
||||
import io.noties.markwon.ext.latex.JLatexMathPlugin
|
||||
import io.noties.markwon.ext.latex.JLatexMathTheme
|
||||
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 java.util.Collections
|
||||
import org.commonmark.node.Node
|
||||
import org.commonmark.parser.Parser
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -63,14 +68,28 @@ class EventHtmlRenderer @Inject constructor(
|
|||
}
|
||||
}
|
||||
})
|
||||
.usePlugin(MarkwonInlineParserPlugin.create())
|
||||
.usePlugin(JLatexMathPlugin.create(44F) { builder ->
|
||||
builder.inlinesEnabled(true)
|
||||
builder.theme().inlinePadding(JLatexMathTheme.Padding.symmetric(24, 8))
|
||||
})
|
||||
} else {
|
||||
builder
|
||||
}.textSetter(PrecomputedFutureTextSetterCompat.create()).build()
|
||||
}
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(MarkwonInlineParser.factoryBuilderNoDefaults()))
|
||||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configure(registry: Registry) {
|
||||
registry.require(MarkwonInlineParserPlugin::class.java, { plugin: MarkwonInlineParserPlugin ->
|
||||
plugin.factoryBuilder().addInlineProcessor(HtmlInlineProcessor())
|
||||
})
|
||||
}
|
||||
})
|
||||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureParser(builder: Parser.Builder) {
|
||||
builder.enabledBlockTypes(Collections.emptySet())
|
||||
}
|
||||
})
|
||||
.textSetter(PrecomputedFutureTextSetterCompat.create())
|
||||
.build()
|
||||
|
||||
val plugins: List<MarkwonPlugin> = markwon.plugins
|
||||
|
||||
|
|
Loading…
Reference in a new issue