Skip to content

Commit

Permalink
fix htmltext2 data corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
X1nto committed Dec 23, 2023
1 parent 01a3dcf commit 5037e62
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.takeOrElse
Expand Down Expand Up @@ -52,7 +53,13 @@ fun HtmlText2(
modifier: Modifier = Modifier,
userScrollEnabled: Boolean = true,
) {
val textCss = typography.asCss(LocalDensity.current)
val density = LocalDensity.current
val textCss = remember(density) {
typography.asCss(density)
}
val escapedText = remember {
text.replace("#", "%23")
}
AndroidView(
modifier = modifier,
factory = {
Expand Down Expand Up @@ -82,7 +89,7 @@ fun HtmlText2(
</style>
</head>
<body>
$text
$escapedText
</body>
</html>
""".trimIndent()
Expand Down

0 comments on commit 5037e62

Please sign in to comment.