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) + } } }