I have a string resource that has some html tags i...
# compose
a
I have a string resource that has some html tags in it. Ex.
"This is a <b>bold</b> text."
In View world I was able to directly use this resource and put it in a TextView as it accepts a
CharSequence
for text. In Compose, however, I need to create an
AnnotatedString
out of this resource to display it in a Text composable. How to do this?
r
You can write parser
c
I've written a library for displaying these kinds of formatted strings that you may find helpful https://github.com/copper-leaf/thistle
👍 1
d
I used this SO answer, which has a file you can simply drop into your project: https://stackoverflow.com/a/68241339/1622788
👍 1
you would write
Text("This is a <b>bold</b> text.".parseHtml())
c
I think Zach K worked on some sort of html parser or something that he handed off to some other community member here. I know that's not necessarily helpful, but I could've sworn that he worked on something like that before joining the Compose team. lol