ru.curs.adocwrapper.utils.HtmlEscaper.kt Maven / Gradle / Ivy
The newest version!
package ru.curs.adocwrapper.utils
class HtmlEscaper {
companion object {
private val codes = mapOf(
"*" to "*",
"-" to "-",
"." to ".",
":" to ":",
";" to ";",
"[" to "[",
"]" to "]",
"{" to "{",
"}" to "}",
"_" to "_",
"/" to "/",
"#" to "#",
"+" to "+",
)
fun getCodes(): Map {
return codes
}
fun escape(text: String): String {
var escaped = text
text.forEach {
if (codes.containsKey(it.toString())) {
escaped = text.replace(it.toString(), codes[it.toString()]!!)
}
}
return escaped.replace("\n", " ")
}
}
}