All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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", " ")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy