replacing links with their content, in the future this should be a representation with ranges of the formatting within the text
This commit is contained in:
parent
299c6af27a
commit
8716500d99
|
@ -63,9 +63,19 @@ fun String.stripTags() = this
|
||||||
} ?: this
|
} ?: this
|
||||||
}
|
}
|
||||||
.trim()
|
.trim()
|
||||||
|
.replaceLinks()
|
||||||
.replace("<em>", "")
|
.replace("<em>", "")
|
||||||
.replace("</em>", "")
|
.replace("</em>", "")
|
||||||
.replace(""", "\"")
|
.replace(""", "\"")
|
||||||
.replace("'", "'")
|
.replace("'", "'")
|
||||||
|
|
||||||
|
private fun String.replaceLinks(): String {
|
||||||
|
return this.indexOfOrNull("<a href=")?.let { start ->
|
||||||
|
val openTagClose = indexOfOrNull("\">")!!
|
||||||
|
val end = indexOfOrNull("</a>")!!
|
||||||
|
val content = this.substring(openTagClose + "\">".length, end)
|
||||||
|
this.replaceRange(start, end + "</a>".length, content)
|
||||||
|
} ?: this
|
||||||
|
}
|
||||||
|
|
||||||
private fun ApiTimelineEvent.TimelineMessage.asTextContent() = this.content as ApiTimelineEvent.TimelineMessage.Content.Text
|
private fun ApiTimelineEvent.TimelineMessage.asTextContent() = this.content as ApiTimelineEvent.TimelineMessage.Content.Text
|
||||||
|
|
Loading…
Reference in New Issue