diff --git a/core/src/main/kotlin/eu/iamgio/quarkdown/ast/quarkdown/block/Container.kt b/core/src/main/kotlin/eu/iamgio/quarkdown/ast/quarkdown/block/Container.kt index 7760ff72..d429c472 100644 --- a/core/src/main/kotlin/eu/iamgio/quarkdown/ast/quarkdown/block/Container.kt +++ b/core/src/main/kotlin/eu/iamgio/quarkdown/ast/quarkdown/block/Container.kt @@ -17,6 +17,7 @@ import eu.iamgio.quarkdown.visitor.node.NodeVisitor * @param borderStyle border style * @param padding whitespace around the content * @param cornerRadius border radius of the container + * @param alignment alignment of the content */ class Container( val foregroundColor: Color? = null, @@ -26,6 +27,7 @@ class Container( val borderStyle: BorderStyle? = null, val padding: Sizes? = null, val cornerRadius: Sizes? = null, + val alignment: Aligned.Alignment? = null, override val children: List, ) : NestableNode { override fun accept(visitor: NodeVisitor): T = visitor.visit(this) 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 bcee0128..2c3a693f 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 @@ -169,6 +169,8 @@ class QuarkdownHtmlNodeRenderer(context: Context) : BaseHtmlNodeRenderer(context // No border style. else -> null } + + "text-align" value node.alignment } } diff --git a/core/src/test/kotlin/eu/iamgio/quarkdown/HtmlNodeRendererTest.kt b/core/src/test/kotlin/eu/iamgio/quarkdown/HtmlNodeRendererTest.kt index 807dc326..066351a7 100644 --- a/core/src/test/kotlin/eu/iamgio/quarkdown/HtmlNodeRendererTest.kt +++ b/core/src/test/kotlin/eu/iamgio/quarkdown/HtmlNodeRendererTest.kt @@ -763,6 +763,7 @@ class HtmlNodeRendererTest { borderWidth = Sizes(all = 1.0.cm), padding = Sizes(2.0.inch, 3.0.inch, 4.0.inch, 5.0.inch), cornerRadius = Sizes(all = 6.0.px), + alignment = Aligned.Alignment.CENTER, children = children, ).render(), ) @@ -772,6 +773,7 @@ class HtmlNodeRendererTest { Container( borderColor = Color(30, 20, 10), borderStyle = Container.BorderStyle.DOTTED, + alignment = Aligned.Alignment.END, children = children, ).render(), ) diff --git a/core/src/test/resources/rendering/quarkdown/container.html b/core/src/test/resources/rendering/quarkdown/container.html index 2f247f3b..cbafcb7b 100644 --- a/core/src/test/resources/rendering/quarkdown/container.html +++ b/core/src/test/resources/rendering/quarkdown/container.html @@ -37,7 +37,7 @@ --- -
+

Foo bar

@@ -50,7 +50,7 @@ --- -
+

Foo bar

diff --git a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Layout.kt b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Layout.kt index 97d1e8fb..e457ed9c 100644 --- a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Layout.kt +++ b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Layout.kt @@ -54,6 +54,7 @@ val Layout: Module = * @param borderStyle border style. Normal (solid) if unset and [borderColor] or [borderWidth] is set * @param padding whitespace around the content. None if unset * @param cornerRadius corner (and border) radius. None if unset + * @param alignment alignment of the content. Default if unset * @param body content to group * @return the new container node */ @@ -65,6 +66,7 @@ fun container( @Name("borderstyle") borderStyle: Container.BorderStyle? = null, @Name("padding") padding: Sizes? = null, @Name("radius") cornerRadius: Sizes? = null, + alignment: Aligned.Alignment? = null, body: MarkdownContent, ) = Container( foregroundColor, @@ -74,6 +76,7 @@ fun container( borderStyle, padding, cornerRadius, + alignment, body.children, ).wrappedAsValue()