From ae954f9b2dea3849ca66a5357e1e4dc4c88aa7e5 Mon Sep 17 00:00:00 2001 From: Giorgio Garofalo Date: Sun, 23 Jun 2024 14:43:21 +0200 Subject: [PATCH] Improve `Stacked` HTML rendering code --- .../rendering/html/QuarkdownHtmlNodeRenderer.kt | 11 ++++++----- .../eu/iamgio/quarkdown/test/FullPipelineTest.kt | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/main/kotlin/eu/iamgio/quarkdown/rendering/html/QuarkdownHtmlNodeRenderer.kt b/core/src/main/kotlin/eu/iamgio/quarkdown/rendering/html/QuarkdownHtmlNodeRenderer.kt index 021798b7..907c129b 100644 --- a/core/src/main/kotlin/eu/iamgio/quarkdown/rendering/html/QuarkdownHtmlNodeRenderer.kt +++ b/core/src/main/kotlin/eu/iamgio/quarkdown/rendering/html/QuarkdownHtmlNodeRenderer.kt @@ -58,17 +58,18 @@ class QuarkdownHtmlNodeRenderer(context: Context) : BaseHtmlNodeRenderer(context override fun visit(node: Aligned) = div("align align-" + node.alignment.name.lowercase(), node.children) override fun visit(node: Stacked): CharSequence { - return tagBuilder("div", node.children) - .attribute("class", "stack stack-" + node.orientation.asCSS) - .style { + return div("stack stack-${node.orientation.asCSS}") { + +node.children + + style { "justify-content" value node.mainAxisAlignment "align-items" value node.crossAxisAlignment "gap" value node.gap } - .build() + } } - override fun visit(node: Clipped) = div("clip-" + node.clip.asCSS, node.children) + override fun visit(node: Clipped) = div("clip-${node.clip.asCSS}", node.children) override fun visit(node: Box) = div("box") { diff --git a/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt b/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt index cf30caec..32ff2c1e 100644 --- a/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt +++ b/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt @@ -224,7 +224,7 @@ class FullPipelineTest { """.trimIndent(), ) { assertEquals( - "
" + + "
" + "

Hello 1\nHello 2

Hello 3

" + "
", it, @@ -242,7 +242,7 @@ class FullPipelineTest { """.trimIndent(), ) { assertEquals( - "
" + + "
" + "

Hello 1

" + "

Hello 2

" + "
Hello 3
" + @@ -272,11 +272,11 @@ class FullPipelineTest { """.trimIndent(), ) { assertEquals( - "
" + - "
" + + "
" + + "
" + "

Quarkdown

A cool language

" + "
" + - "
" + + "
" + "
" + "

\"\"

" + "
" +