Skip to content

Commit

Permalink
Add linkify plugin to markwon (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin authored Jun 10, 2023
1 parent bb15433 commit 1687634
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dependencies {
// Markdown support
implementation 'io.noties.markwon:core:4.6.2'
implementation 'io.noties.markwon:image-coil:4.6.2'
implementation 'io.noties.markwon:linkify:4.6.2'

// Accompanist
implementation 'com.google.accompanist:accompanist-pager:0.30.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.res.ResourcesCompat
import coil.ImageLoader
import com.jerboa.R
import com.jerboa.openLink
import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.Markwon
import io.noties.markwon.MarkwonConfiguration
import io.noties.markwon.image.coil.CoilImagesPlugin
import io.noties.markwon.linkify.LinkifyPlugin

object MarkdownHelper {
private var markwon: Markwon? = null
Expand All @@ -34,6 +38,14 @@ object MarkdownHelper {

markwon = Markwon.builder(context)
.usePlugin(CoilImagesPlugin.create(context, loader))
.usePlugin(LinkifyPlugin.create())
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
builder.linkResolver { view, link ->
link?.let { openLink(link, view.context) }
}
}
})
.build()
}

Expand Down

0 comments on commit 1687634

Please sign in to comment.