https://kotlinlang.org logo
Title
e

Evgeniy Zemtsov

05/18/2023, 12:19 PM
Hi, everyone! I'm trying to use kotlinx-html for building formatted messages for Telegram. Telegram supports only limited number of tags (docs), So basically, I need to produce a kinda-html-document without a top level tag. And I'm struggling with finding a nice way to do that 🙂 The best I've come up with so far is something like that:
buildString {
            appendHTML().b { +"Here is a list of users" }
            append("\n\n")
            for (user in users) {
                appendHTML().b { +"${user.type}: "}
                append("${user.login}\n")
            }
        }
Maybe anyone has a better example?
Maybe there is a way to wrap everything into dummy div, then acquire and render it's contents without a tag itself. I've tried looking into that, but quickly drowned in org.w3c.dom.* :melting_face: