### Custom SpanMapper usage
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Customize the appearance of specific spans using a spanMappers map. This example changes the link color and text decoration for URLSpan.
```kotlin
val content = remember {
"Welcome to my GitHub".fromHtml(
spanMappers = mapOf(
URLSpan::class to {
linkColor = Color.Red
textDecoration = TextDecoration.LineThrough
}
)
)
}
AnnotatedText(
text = content,
...
)
```
--------------------------------
### Default Compose Text + Modifier usage
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Use AnnotatedText with the default Compose Text composable. This example shows how to apply the annotatedTextParagraphContents and annotatedTextClickable modifiers to handle layout and URL clicks.
```kotlin
val content = remember {
"
Hello World!
".fromHtml()
}
val layoutResult = remember {
mutableStateOf(null)
}
Text(
text = content.annotatedString,
inlineContent = content.getInlineContentMap(),
onTextLayout = { layoutResult.value = it },
modifier = Modifier
.annotatedTextParagraphContents(content, layoutResult)
.annotatedTextClickable(content, layoutResult) { url ->
println(url)
}
)
```
--------------------------------
### Spanned asAnnotatedString usage
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Convert a Spanned string to an AnnotatedString and pass it to AnnotatedText. This example uses buildSpannedString with an UnderlineSpan.
```kotlin
val spanned = buildSpannedString {
append("Hello ")
inSpans(UnderlineSpan()) {
append("World!")
}
}
AnnotatedText(
text = spanned.asAnnotatedString(),
...
)
```
--------------------------------
### From HTML usage
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Create AnnotatedText from an HTML string using the fromHtml() extension. The HTML is parsed and rendered as annotated text.
```kotlin
AnnotatedText(
text = "Hello World!".fromHtml(),
...
)
```
--------------------------------
### URL onClick usage
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Handle URL clicks in AnnotatedText. The fromHtml() function is used with a linkColor parameter, and the onURLClick callback receives the clicked URL.
```kotlin
AnnotatedText(
text = "Link to GitHub".fromHtml(linkColor = Color.Blue),
onURLClick = { url ->
println(url)
}
)
```
--------------------------------
### Gradle dependency for AnnotatedText
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Add the AnnotatedText library to your Gradle project. The library is available in mavenCentral().
```gradle
implementation 'io.github.aghajari:AnnotatedText:1.0.3'
```
--------------------------------
### Maven dependency for AnnotatedText
Source: https://github.com/aghajari/annotatedtext/blob/main/README.md
Add the AnnotatedText library to your Maven project. The library is available in mavenCentral().
```xml
io.github.aghajari
AnnotatedText
1.0.3
pom
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.