Skip to content

Commit dcb5b7b

Browse files
authored
Update README.md
1 parent f54c574 commit dcb5b7b

File tree

1 file changed

+10
-49
lines changed

1 file changed

+10
-49
lines changed

README.md

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
<a href="https://github.com/ch4rl3x/HtmlText/actions?query=workflow%3ABuild"><img src="https://github.com/ch4rl3x/HtmlText/workflows/build.yml/badge.svg" alt="Build"></a>
1+
<a href="https://github.com/ch4rl3x/HtmlText/actions?query=workflow%3ABuild"><img src="https://github.com/ch4rl3x/HtmlText/actions/workflows/build.yml/badge.svg" alt="Build"></a>
22
<a href="https://www.codefactor.io/repository/github/ch4rl3x/HtmlText"><img src="https://www.codefactor.io/repository/github/ch4rl3x/HtmlText/badge" alt="CodeFactor" /></a>
3+
<a href="https://repo1.maven.org/maven2/de/charlex/compose/material3/material3-html-text/"><img src="https://img.shields.io/maven-central/v/de.charlex.compose.material3/material3-html-text" alt="Maven Central" /></a>
34

4-
| Material | Material 3 |
5-
|-----|------------|
6-
| <a href="https://repo1.maven.org/maven2/de/charlex/compose/material/material-html-text/"><img src="https://img.shields.io/maven-central/v/de.charlex.compose.material/material-html-text" alt="Maven Central" /></a> | <a href="https://repo1.maven.org/maven2/de/charlex/compose/material3/material3-html-text/"><img src="https://img.shields.io/maven-central/v/de.charlex.compose.material3/material3-html-text" alt="Maven Central" /></a> |
75

86
# HtmlText
97

108
`HtmlText` is a Kotlin Multiplatform library that allows you to render HTML content as Compose `AnnotatedStrings. It supports basic formatting, hyperlinks, and color styling in a multiplatform-friendly way.
119

1210
> [!NOTE]
13-
> 🚀 RevealSwipe is now Compose Multiplatform
11+
> 🚀 HtmlText is now Compose Multiplatform
1412
1513
## Supported HTML tags
1614

@@ -34,76 +32,39 @@
3432
To use colors like `MaterialTheme.colors.primary` in `HtmlText`, map simple colors.
3533
```kotlin
3634
HtmlText(
37-
textId = R.string.hello_world,
35+
stringId = R.string.hello_world_cdata,
3836
colorMapping = mapOf(Color.Red to MaterialTheme.colors.primary)
3937
)
4038
```
4139
```xml
4240
<resources>
43-
<string name="hello_world">"Hello <span style="color: red">World</span>"</string>
44-
</resources>
45-
```
46-
47-
## String arguments in HtmlText
48-
To use string arguments with `HtmlText`, use CDATA
49-
```kotlin
50-
HtmlText(
51-
text = stringResource(R.string.hello_world, "Hello")
52-
)
53-
```
54-
```xml
55-
<resources>
56-
<string name="hello_world"><![CDATA[%1$s World]]></string>
57-
</resources>
58-
```
59-
60-
## Combine MaterialTheme colors and string arguments in HtmlText
61-
You can combine colorMapping with string arguments (CDATA) and all other HTML tags. If you use CDATA, you have to escape double quotes.
62-
```xml
63-
<resources>
64-
<string name="hello_world"><![CDATA[Hello <span style=\"color: red\">World</span>]]></string>
41+
<string name="hello_world_escaped">Hello &lt;span style="color: #FF0000"&gt;World&lt;/span&gt;</string>
42+
<string name="hello_world_cdata"><![CDATA[Hello <span style="color: #FF0000">World</span>]]></string>
6543
</resources>
6644
```
6745

46+
## Preview
6847

48+
![HtmlText](https://github.com/ch4rl3x/HtmlText/blob/main/art/screenshot.png)
6949

7050
## Dependency
7151

7252
Add actual HtmlText library:
7353

7454
```groovy
7555
dependencies {
76-
implementation 'de.charlex.compose.material:material-html-text:2.1.0-beta01'
56+
implementation 'de.charlex.compose.material:material-html-text:3.0.0-beta01'
7757
}
7858
```
7959

8060
or
8161

8262
```groovy
8363
dependencies {
84-
implementation 'de.charlex.compose.material3:material3-html-text:2.1.0-beta01'
64+
implementation 'de.charlex.compose.material3:material3-html-text:3.0.0-beta01'
8565
}
8666
```
8767

88-
## How does it work?
89-
90-
Use it like a normal Text composable
91-
92-
```kotlin
93-
HtmlText(textId = R.string.hello_world)
94-
```
95-
96-
```xml
97-
<resources>
98-
<string name="hello_world">Hello <b>World</b>. This <i><strike>text</strike>sentence</i> is form<b>att<u>ed</u></b> in simple html. <a href="https://github.com/ch4rl3x/HtmlText">HtmlText</a></string>
99-
</resources>
100-
```
101-
102-
## Preview
103-
104-
![HtmlText](https://github.com/ch4rl3x/HtmlText/blob/main/art/screenshot.png)
105-
106-
10768
License
10869
--------
10970

0 commit comments

Comments
 (0)