From 0e445d4bbb394a3c6dac2a91c0a95fd0a29c0351 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 5 Oct 2024 17:47:16 +0300 Subject: [PATCH] Revert to use string builder instead of document builder --- .../kotlin/space/kscience/snark/html/HtmlPage.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/snark-html/src/jvmMain/kotlin/space/kscience/snark/html/HtmlPage.kt b/snark-html/src/jvmMain/kotlin/space/kscience/snark/html/HtmlPage.kt index d1069fb..9aeda6d 100644 --- a/snark-html/src/jvmMain/kotlin/space/kscience/snark/html/HtmlPage.kt +++ b/snark-html/src/jvmMain/kotlin/space/kscience/snark/html/HtmlPage.kt @@ -1,11 +1,8 @@ package space.kscience.snark.html -import kotlinx.css.html import kotlinx.html.HTML -import kotlinx.html.dom.append -import kotlinx.html.dom.document -import kotlinx.html.dom.serialize import kotlinx.html.html +import kotlinx.html.stream.createHTML import space.kscience.dataforge.data.DataSink import space.kscience.dataforge.data.DataTree import space.kscience.dataforge.data.wrap @@ -19,19 +16,21 @@ public fun interface HtmlPage { public companion object { + private const val HTML_HEADER = "\n" + public fun createHtmlString( pageContext: PageContext, dataSet: DataTree<*>?, page: HtmlPage, - ): String = document { - append.html { + ): String = HTML_HEADER + createHTML(true).run { + html { with(PageContextWithData(pageContext, dataSet ?: DataTree.EMPTY)) { with(page) { renderPage() } } } - }.serialize(true) + } } }