Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatted_body being parsed as Markdown #6357

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6357.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix backslash escapes in formatted messages
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ 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 org.commonmark.node.Node
import org.commonmark.parser.Parser
import timber.log.Timber
import java.util.Collections
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -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 ->
Copy link
Contributor

@ouchadam ouchadam Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my understanding, we can combine the inline parser plugin creation with the configuration

 .usePlugin(
  MarkwonInlineParserPlugin.create(
    MarkwonInlineParser.factoryBuilderNoDefaults().addInlineProcessor(HtmlInlineProcessor()),
  )
)

plugin.factoryBuilder().addInlineProcessor(HtmlInlineProcessor())
})
}
})
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureParser(builder: Parser.Builder) {
builder.enabledBlockTypes(Collections.emptySet())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with kotlin the idiomatic way to declare an empty set is with kotlin.collections emptySet()

}
})
.textSetter(PrecomputedFutureTextSetterCompat.create())
.build()

val plugins: List<MarkwonPlugin> = markwon.plugins

Expand Down