From 349d841a31a172c810c864725d1d5b0b23bc96be Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Tue, 7 Dec 2021 18:13:29 +0300 Subject: Support deeply nested description terms and details --- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 22 ++++++++++++++++------ .../pages/comments/DocTagToContentConverter.kt | 2 +- .../test/kotlin/renderers/html/ListStylesTest.kt | 2 +- .../transformers/CommentsToContentConverterTest.kt | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 304b96fa..727b009c 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -111,6 +111,12 @@ open class HtmlRenderer( ) { childrenCallback() } node.extra[InsertTemplateExtra] != null -> node.extra[InsertTemplateExtra]?.let { templateCommand(it.command) } ?: Unit + node.hasStyle(ListStyle.DescriptionTerm) -> DT(emptyMap(), consumer).visit { + this@wrapGroup.childrenCallback() + } + node.hasStyle(ListStyle.DescriptionDetails) -> DD(emptyMap(), consumer).visit { + this@wrapGroup.childrenCallback() + } else -> childrenCallback() } } @@ -294,12 +300,16 @@ open class HtmlRenderer( node: ContentList, pageContext: ContentPage, sourceSetRestriction: Set? - ) = if (node.ordered) { - ol { buildListItems(node.children, pageContext, sourceSetRestriction) } - } else if (node.hasStyle(ListStyle.DescriptionList)) { - dl { buildListItems(node.children, pageContext, sourceSetRestriction) } - } else { - ul { buildListItems(node.children, pageContext, sourceSetRestriction) } + ) = when { + node.ordered -> { + ol { buildListItems(node.children, pageContext, sourceSetRestriction) } + } + node.hasStyle(ListStyle.DescriptionList) -> { + dl { buildListItems(node.children, pageContext, sourceSetRestriction) } + } + else -> { + ul { buildListItems(node.children, pageContext, sourceSetRestriction) } + } } open fun DL.buildListItems( diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt index 2b4317c5..c38edea8 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt @@ -46,7 +46,7 @@ open class DocTagToContentConverter : CommentsToContentConverter { ordered, dci, sourceSets.toDisplaySourceSets(), - if (newStyles.isEmpty()) styles else styles + newStyles, + styles + newStyles, ((PropertyContainer.empty()) + SimpleAttr("start", start.toString())) ) ) diff --git a/plugins/base/src/test/kotlin/renderers/html/ListStylesTest.kt b/plugins/base/src/test/kotlin/renderers/html/ListStylesTest.kt index d578ba5e..8b11dad1 100644 --- a/plugins/base/src/test/kotlin/renderers/html/ListStylesTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/ListStylesTest.kt @@ -38,4 +38,4 @@ class ListStylesTest : HtmlRenderingOnlyTestBase() { ) ) } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt b/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt index 6d8730f1..9a77172b 100644 --- a/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt +++ b/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt @@ -473,4 +473,4 @@ class CommentsToContentConverterTest { } } } -} \ No newline at end of file +} -- cgit