{"id":358845,"date":"2024-05-21T00:20:18","date_gmt":"2024-05-21T00:20:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358845"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358845","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 Compose \u0447\u0435\u0440\u0435\u0437 Spannable<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442 \u043e\u0442 \u0410\u043d\u0434\u0440\u043e\u0438\u0434-\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u043d\u043a\u0430 <a href=\"https:\/\/xn--d1aqf.xn--p1ai\/\">\u0414\u041e\u041c.\u0420\u0424<\/a>! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <a href=\"https:\/\/developer.android.com\/reference\/kotlin\/androidx\/compose\/ui\/text\/AnnotatedString.Builder\">AnnotatedString<\/a>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0443\u0441\u043a\u0430\u043c\u0438, \u0442\u0430\u043a \u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0435\u043c, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ol>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u043a \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442, \u0438 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0441\u0442\u0438\u043b\u0435\u0439, \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0421\u00a0\u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443? \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442 \u043d\u0430\u0441 \u043e\u0442 \u0444\u0438\u043a\u0441\u0430 \u0431\u0430\u0433\u043e\u0432. \u0418\u043b\u0438 \u0436\u0435 \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0435\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 Compose.<\/p>\n<h3>Html \u0442\u0435\u043a\u0441\u0442 \u0438 Spannable<\/h3>\n<pre><code class=\"kotlin\">val htmlText = \"&lt;b>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e compose&lt;\/b> \\n&lt;a href=\\\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/compose\\\" target=\\\"_blank\\\">\" + \"\u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442&lt;\/a>, \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e\" \/\/ Spanned \u0441\u044a\u0435\u0434\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0441\u0438\u043c\u0432\u043e\u043b\u044b \\n, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0442\u0435\u0433 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 &lt;br> val formattedText = Html.fromHtml(htmlText.replace(\"\\n\", \"&lt;br>\"), Html.FROM_HTML_MODE_COMPACT)<\/code><\/pre>\n<p>Html.fromHtml \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 Spanned. \u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Spannable. \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. TextView \u0443\u043c\u0435\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 public api jetpack Compose. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 Spans \u0441\u0442\u0438\u043b\u0438 \u0432 \u0442\u043e, \u0447\u0442\u043e \u0441\u044a\u0435\u0441\u0442 Compose. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f AnnotatedString.<\/p>\n<pre><code class=\"kotlin\">const val URL_TAG = \"url\"  fun Spanned.toAnnotateString(     baseSpanStyle: SpanStyle?,     linkColor: Color ): AnnotatedString {     return buildAnnotatedString {         val spanned = this@toAnnotateString         append(spanned.toString())         baseSpanStyle?.let { addStyle(it, 0, length) }         getSpans(0, spanned.length, Any::class.java).forEach { span ->             val start = getSpanStart(span)             val end = getSpanEnd(span)             when (span) {                 is StyleSpan -> when (span.style) {                     Typeface.BOLD -> addStyle(SpanStyle(fontWeight = FontWeight.Bold), start, end)                     Typeface.ITALIC -> addStyle(SpanStyle(fontStyle = FontStyle.Italic), start, end)                     Typeface.BOLD_ITALIC -> addStyle(                         SpanStyle(fontWeight = FontWeight.Bold, fontStyle = FontStyle.Italic),                         start,                         end                     )                 }                 is UnderlineSpan -> addStyle(SpanStyle(textDecoration = TextDecoration.Underline), start, end)                 is ForegroundColorSpan -> addStyle(SpanStyle(color = Color(span.foregroundColor)), start, end)                 is URLSpan -> {                     addStyle(                         SpanStyle(                             textDecoration = TextDecoration.Underline,                             color = linkColor                         ), start, end                     )                     addStringAnnotation(URL_TAG, span.url, start, end)                 }             }         }     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0444\u043e\u0440\u043c\u0438\u043b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d Spanned.toAnnotateString. \u0417\u0430\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e &#8212; \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c Spans, \u0441\u0442\u0438\u043b\u0438\u0437\u0443\u044f \u0442\u0435\u043a\u0441\u0442 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e addStyle. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c URLSpan, \u043e\u043d \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0422\u0435\u0445 \u0441\u043f\u0430\u043d\u043e\u0432, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0435, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0412\u044b \u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u0438, \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0432 \u0441\u0442\u0438\u043b\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0441\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438, \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 Compose.<\/p>\n<pre><code class=\"kotlin\">@Composable fun HtmlTextField(     modifier: Modifier = Modifier,     baseSpanStyle: SpanStyle? = null,     isHighlightLink: Boolean = false,     style: TextStyle = LocalTextStyle.current,     onUrlClick: ((url: String) -> Unit)? = null ) {     val htmlText = \"&lt;b>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e compose&lt;\/b> \\n&lt;a href=\\\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/compose\\\" target=\\\"_blank\\\">\" +     \"\u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442&lt;\/a>, \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e\"     val formattedText = Html.fromHtml(htmlText.replace(\"\\n\", \"&lt;br>\"), Html.FROM_HTML_MODE_COMPACT)     val uriHandler = LocalUriHandler.current     val linkColor = if (isHighlightLink) Color.Blue else Color.Unspecified     val annotatedString = formattedText.toAnnotateString(baseSpanStyle = baseSpanStyle, linkColor = linkColor)     ClickableText(         modifier = modifier,         text = annotatedString,         style = style,     ) { offset ->         annotatedString.getStringAnnotations(URL_TAG, offset, offset).firstOrNull()?.let {             onUrlClick?.let { click -> click(it.item) } ?: uriHandler.openUri(it.item)         }     } }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4a2\/f27\/b9a\/4a2f27b9aacfa1e6f6a43638a560ccba.png\" alt=\"\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 html \u0432 Compose\" title=\"\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 html \u0432 Compose\" width=\"810\" height=\"230\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4a2\/f27\/b9a\/4a2f27b9aacfa1e6f6a43638a560ccba.png\"\/><\/p>\n<div><figcaption>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 html \u0432 Compose<\/figcaption><\/div>\n<\/figure>\n<p>ClickableText \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u0435. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435. <\/p>\n<h2>\u041d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Linkify<\/h2>\n<p>\u0423 TextView \u0435\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 autoLink, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430 \u043d\u0430\u0441 \u0438\u0449\u0435\u0442 \u0438 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0438\u043a\u0438 \u043f\u043e \u043d\u0438\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f, \u0442\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/developer.android.com\/reference\/android\/text\/util\/Linkify\">Linkify<\/a>, \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 addLinks, \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 Span \u043d\u0430 \u0432\u0445\u043e\u0434 \u0438 \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c &#8212; \u0442\u0438\u043f \u043c\u0430\u0441\u043a\u0438. <\/p>\n<pre><code class=\"kotlin\">@Composable fun Message() {     val someText = \"\u0425\u043e\u0447\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u044c https:\/\/developer.android.com, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e?\"     val uriHandler = LocalUriHandler.current     val spannedText = someText.toSpannable() \/\/ \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 Spannable, \u0442\u0430\u043a \u043a\u0430\u043a Linkify \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e Spannable     Linkify.addLinks(spannedText, Linkify.WEB_URLS) \/\/ \u0418\u0449\u0435\u043c \u0438 \u0440\u0430\u0437\u043c\u0435\u0447\u0430\u0435\u043c URLSpan     val annotatedString = spannedText.toAnnotateString(         baseSpanStyle = SpanStyle(             color = Color.Black,         ),         linkColor = Color.Blue     )     ClickableText(         modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),         text = annotatedString,         style = MaterialTheme.typography.bodyLarge,         onClick = { offset ->             annotatedString.getStringAnnotations(URL_TAG, offset, offset).firstOrNull()?.let {                 uriHandler.openUri(it.item)             }         }     ) }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b35\/661\/7a6\/b356617a659efdd63d69aeb12fdc2636.png\" alt=\"\u0421\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0441 \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439\" title=\"\u0421\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0441 \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439\" width=\"810\" height=\"198\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b35\/661\/7a6\/b356617a659efdd63d69aeb12fdc2636.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0441 \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Spannable \u0438 Linkify \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043b\u0435\u0442\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0442\u0438\u043b\u0438 \u0438 \u0438\u0437 \u0441\u0432\u043e\u0435\u0439 \u0434\u0438\u0437\u0430\u0439\u043d-\u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043a\u0430\u043a-\u0442\u043e \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0440\u0435\u0448\u0430\u043b\u0438 \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/770796\/\"> https:\/\/habr.com\/ru\/articles\/770796\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442 \u043e\u0442 \u0410\u043d\u0434\u0440\u043e\u0438\u0434-\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u043d\u043a\u0430 <a href=\"https:\/\/xn--d1aqf.xn--p1ai\/\">\u0414\u041e\u041c.\u0420\u0424<\/a>! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <a href=\"https:\/\/developer.android.com\/reference\/kotlin\/androidx\/compose\/ui\/text\/AnnotatedString.Builder\">AnnotatedString<\/a>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0443\u0441\u043a\u0430\u043c\u0438, \u0442\u0430\u043a \u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0435\u043c, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ol>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u043a \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442, \u0438 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0441\u0442\u0438\u043b\u0435\u0439, \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a html \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0421\u00a0\u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443? \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442 \u043d\u0430\u0441 \u043e\u0442 \u0444\u0438\u043a\u0441\u0430 \u0431\u0430\u0433\u043e\u0432. \u0418\u043b\u0438 \u0436\u0435 \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0435\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 Compose.<\/p>\n<h3>Html \u0442\u0435\u043a\u0441\u0442 \u0438 Spannable<\/h3>\n<pre><code class=\"kotlin\">val htmlText = \"&lt;b>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e compose&lt;\/b> \\n&lt;a href=\\\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/compose\\\" target=\\\"_blank\\\">\" + \"\u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442&lt;\/a>, \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e\" \/\/ Spanned \u0441\u044a\u0435\u0434\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0441\u0438\u043c\u0432\u043e\u043b\u044b \\n, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0442\u0435\u0433 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 &lt;br> val formattedText = Html.fromHtml(htmlText.replace(\"\\n\", \"&lt;br>\"), Html.FROM_HTML_MODE_COMPACT)<\/code><\/pre>\n<p>Html.fromHtml \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 Spanned. \u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Spannable. \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0440\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. TextView \u0443\u043c\u0435\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 public api jetpack Compose. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 Spans \u0441\u0442\u0438\u043b\u0438 \u0432 \u0442\u043e, \u0447\u0442\u043e \u0441\u044a\u0435\u0441\u0442 Compose. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f AnnotatedString.<\/p>\n<pre><code class=\"kotlin\">const val URL_TAG = \"url\"  fun Spanned.toAnnotateString(     baseSpanStyle: SpanStyle?,     linkColor: Color ): AnnotatedString {     return buildAnnotatedString {         val spanned = this@toAnnotateString         append(spanned.toString())         baseSpanStyle?.let { addStyle(it, 0, length) }         getSpans(0, spanned.length, Any::class.java).forEach { span ->             val start = getSpanStart(span)             val end = getSpanEnd(span)             when (span) {                 is StyleSpan -> when (span.style) {                     Typeface.BOLD -> addStyle(SpanStyle(fontWeight = FontWeight.Bold), start, end)                     Typeface.ITALIC -> addStyle(SpanStyle(fontStyle = FontStyle.Italic), start, end)                     Typeface.BOLD_ITALIC -> addStyle(                         SpanStyle(fontWeight = FontWeight.Bold, fontStyle = FontStyle.Italic),                         start,                         end                     )                 }                 is UnderlineSpan -> addStyle(SpanStyle(textDecoration = TextDecoration.Underline), start, end)                 is ForegroundColorSpan -> addStyle(SpanStyle(color = Color(span.foregroundColor)), start, end)                 is URLSpan -> {                     addStyle(                         SpanStyle(                             textDecoration = TextDecoration.Underline,                             color = linkColor                         ), start, end                     )                     addStringAnnotation(URL_TAG, span.url, start, end)                 }             }         }     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0444\u043e\u0440\u043c\u0438\u043b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d Spanned.toAnnotateString. \u0417\u0430\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e &#8212; \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c Spans, \u0441\u0442\u0438\u043b\u0438\u0437\u0443\u044f \u0442\u0435\u043a\u0441\u0442 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e addStyle. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c URLSpan, \u043e\u043d \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0422\u0435\u0445 \u0441\u043f\u0430\u043d\u043e\u0432, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0435, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0412\u044b \u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u0438, \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0432 \u0441\u0442\u0438\u043b\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0441\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438, \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 Compose.<\/p>\n<pre><code class=\"kotlin\">@Composable fun HtmlTextField(     modifier: Modifier = Modifier,     baseSpanStyle: SpanStyle? = null,     isHighlightLink: Boolean = false,     style: TextStyle = LocalTextStyle.current,     onUrlClick: ((url: String) -> Unit)? = null ) {     val htmlText = \"&lt;b>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e compose&lt;\/b> \\n&lt;a href=\\\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/compose\\\" target=\\\"_blank\\\">\" +     \"\u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0442\u0435\u043a\u0441\u0442&lt;\/a>, \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e\"     val formattedText = Html.fromHtml(htmlText.replace(\"\\n\", \"&lt;br>\"), Html.FROM_HTML_MODE_COMPACT)     val uriHandler = LocalUriHandler.current     val linkColor = if (isHighlightLink) Color.Blue else Color.Unspecified     val annotatedString = formattedText.toAnnotateString(baseSpanStyle = baseSpanStyle, linkColor = linkColor)     ClickableText(         modifier = modifier,         text = annotatedString,         style = style,     ) { offset ->         annotatedString.getStringAnnotations(URL_TAG, offset, offset).firstOrNull()?.let {             onUrlClick?.let { click -> click(it.item) } ?: uriHandler.openUri(it.item)         }     } }<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 html \u0432 Compose<\/figcaption><\/div>\n<\/figure>\n<p>ClickableText \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u0435. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435. <\/p>\n<h2>\u041d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Linkify<\/h2>\n<p>\u0423 TextView \u0435\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 autoLink, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430 \u043d\u0430\u0441 \u0438\u0449\u0435\u0442 \u0438 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0438\u043a\u0438 \u043f\u043e \u043d\u0438\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f, \u0442\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/developer.android.com\/reference\/android\/text\/util\/Linkify\">Linkify<\/a>, \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 addLinks, \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 Span \u043d\u0430 \u0432\u0445\u043e\u0434 \u0438 \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c &#8212; \u0442\u0438\u043f \u043c\u0430\u0441\u043a\u0438. <\/p>\n<pre><code class=\"kotlin\">@Composable fun Message() {     val someText = \"\u0425\u043e\u0447\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u044c https:\/\/developer.android.com, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e?\"     val uriHandler = LocalUriHandler.current     val spannedText = someText.toSpannable() \/\/ \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 Spannable, \u0442\u0430\u043a \u043a\u0430\u043a Linkify \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e Spannable     Linkify.addLinks(spannedText, Linkify.WEB_URLS) \/\/ \u0418\u0449\u0435\u043c \u0438 \u0440\u0430\u0437\u043c\u0435\u0447\u0430\u0435\u043c URLSpan     val annotatedString = spannedText.toAnnotateString(         baseSpanStyle = SpanStyle(             color = Color.Black,         ),         linkColor = Color.Blue     )     ClickableText(         modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),         text = annotatedString,         style = MaterialTheme.typography.bodyLarge,         onClick = { offset ->             annotatedString.getStringAnnotations(URL_TAG, offset, offset).firstOrNull()?.let {                 uriHandler.openUri(it.item)             }         }     ) }<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0441 \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Spannable \u0438 Linkify \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043b\u0435\u0442\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0442\u0438\u043b\u0438 \u0438 \u0438\u0437 \u0441\u0432\u043e\u0435\u0439 \u0434\u0438\u0437\u0430\u0439\u043d-\u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043a\u0430\u043a-\u0442\u043e \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0440\u0435\u0448\u0430\u043b\u0438 \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/770796\/\"> https:\/\/habr.com\/ru\/articles\/770796\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-358845","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358845"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358845\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}