stripping out more html tags from text

This commit is contained in:
Adam Brown 2022-10-04 20:51:57 +01:00
parent 04f1dfe7ca
commit 0a982ff53f
1 changed files with 9 additions and 2 deletions

View File

@ -64,10 +64,17 @@ fun String.stripTags() = this
}
.trim()
.replaceLinks()
.replace("<em>", "")
.replace("</em>", "")
.removeTag("p")
.removeTag("em")
.removeTag("strong")
.removeTag("code")
.removeTag("pre")
.replace("&quot;", "\"")
.replace("&#39;", "'")
.replace("<br />", "\n")
.replace("<br/>", "\n")
private fun String.removeTag(name: String) = this.replace("<$name>", "").replace("/$name>", "")
private fun String.replaceLinks(): String {
return this.indexOfOrNull("<a href=")?.let { start ->