noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.68k stars 298 forks source link

How do you split into multiple spans? #447

Closed LagradOst closed 10 months ago

LagradOst commented 12 months ago

I want to be able to render the spans separately due to both performance and customizability because right now android struggles to render huge textviews and even more so when images are involved. To do this I want to use a recycleview however I dont know how to do that, the best I have been able to achieve is

val renderResult = markwon.render(markwon.parse(...))
textAdapter.submitList(renderResult.getSpans<Any>().toMutableList())

however I cant render the spans like EmphasisSpan in a textview as they are not spannable. How should I split up the spans and render them into seperate textviews/imageviews? Normally when not using markwon I would simply split at newlines and let the recycleview use the substrings to render to a sepearte textview but I still want to keep the formatting and image support markwon has.

LagradOst commented 12 months ago

Even when trying to use getSpanStart and getSpanEnd I get much shorter strings than what is actually expected or am I missing something because I cant do spanned.substring(spanned.getSpanStart(obj),spanned.getSpanEnd(obj)) image