r/androiddev • • Oct 15 '26

I built a native Markdown renderer for Jetpack Compose, now with tap-to-reveal text, LaTeX math and tree-sitter code highlighting

enriched-markdown-android is an open-source Markdown renderer for Jetpack Compose. Parsing is md4c over JNI, rendering is native Android text, so you get platform selection handles, copy and TalkBack for free.

What's new in 0.3.0:

  • Spoilers - ||text|| is drawn transparent and concealed by an animated particle overlay on the text view's canvas, tap to reveal. You can plug in your own overlay with a draw callback per concealed slice.
  • LaTeX math – $inline$ and $$block$$, wide equations scroll sideways, long-press to copy.
  • Syntax highlighting – fenced code colored by tree-sitter, 14 grammars, every token type themeable.
  • Better code blocks – language header, copy button, long lines scroll instead of wrapping.
  • Highlight – ==text== with `Flags(highlight = true)`.
  • Optional plugins – math and highlighting are separate artifacts, so you only add what you need.
  • Native Selection – Standard Android text selection handles and native copy behavior.

💎 Available on Maven Central:

dependencies {
  implementation("com.swmansion.enriched.markdown:compose:0.3.0")
  implementation("com.swmansion.enriched.markdown:math:0.3.0")           // optional
  implementation("com.swmansion.enriched.markdown:code-highlight:0.3.0") // optional
}

Quick Usage:

MarkdownPlugins(LatexMathPlugin, CodeHighlightPlugin) {
  EnrichedMarkdownText(
    markdown = content,
    flags = Flags(highlight = true),
    onLinkClick = { url -> openUrl(url) },
  )
}

GitHub & Docs:
https://github.com/software-mansion/enriched-markdown/blob/main/packages/enriched-markdown-android/README.md

85 Upvotes

8 comments sorted by

6

u/KainTae0922 Oct 15 '26

This is long overdue, I've been waiting for someone to do this 🙏 I'm not updated in android space now, maybe someone already did this... Thank you OP 🥰 I will star this repo.

2

u/Sea-Arm9235 Oct 15 '26

Thanks, glad it's useful! The library is in active development, so if you try it and something's missing or off, open an issue or just reply here. Feedback is very welcome 🙂

3

u/ravi_k-98 Oct 15 '26

Great! I had made my own hacky utility for bullet points in one of my apps but thanks to this I can opt for something much cleaner.

I'll definitely try it!

1

u/Sea-Arm9235 Oct 15 '26

Nice, that's exactly the kind of thing it should replace. Give it a go, and if anything about the list rendering (or anything else) doesn't fit your app, let me know. It's in active development and that kind of feedback shapes what gets fixed next 🚀

2

u/Infamous_Sorbet4021 Oct 16 '26

Do have plans for making also available for Compose Multiplatform in the future?

3

u/Sea-Arm9235 Oct 16 '26

Yes, we have a plan for this, and I think it can be done in the near future 🙂

2

u/GingerGigiCat Oct 16 '26

Compose multiplatform would be awesome, I'll need to implement markdown in a project soon so it would be great if there's a library to use instead

2

u/I_DontFeelGood_2 Oct 16 '26

finally something nice in this sub