aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-02-28 15:33:54 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-04 14:28:14 +0100
commit8a439143252026b0bda1d1f23c688c861ae0c528 (patch)
tree746f2222d7be7079aeb10d6782e6713df7d79ca0 /plugins/base/src/main
parent763f53987fe803eac412d8549ba2e07ef9560107 (diff)
downloaddokka-8a439143252026b0bda1d1f23c688c861ae0c528.tar.gz
dokka-8a439143252026b0bda1d1f23c688c861ae0c528.tar.bz2
dokka-8a439143252026b0bda1d1f23c688c861ae0c528.zip
Adds group wraping
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt5
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt10
2 files changed, 14 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index 9c22c879..960a39fd 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -32,10 +32,13 @@ abstract class DefaultRenderer<T>(
abstract fun buildPage(page: ContentPage, content: (T, ContentPage) -> Unit): String
abstract fun buildError(node: ContentNode)
- open fun T.buildGroup(node: ContentGroup, pageContext: ContentPage) {
+ open fun T.buildGroup(node: ContentGroup, pageContext: ContentPage) = wrapGroup(node, pageContext) {
node.children.forEach { it.build(this, pageContext) }
}
+ open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) =
+ childrenCallback()
+
open fun T.buildLinkText(nodes: List<ContentNode>, pageContext: ContentPage) {
nodes.forEach { it.build(this, pageContext) }
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 8bf00043..dcd65c21 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -23,6 +23,16 @@ open class HtmlRenderer(
StyleAndScriptsAppender
)
+ override fun FlowContent.wrapGroup(
+ node: ContentGroup,
+ pageContext: ContentPage,
+ childrenCallback: FlowContent.() -> Unit
+ ) = when {
+ node.style.contains(TextStyle.Paragraph) -> p { childrenCallback() }
+ node.style.contains(TextStyle.Block) -> div { childrenCallback() }
+ else -> childrenCallback()
+ }
+
override fun FlowContent.buildList(node: ContentList, pageContext: ContentPage) =
if (node.ordered) ol {
buildListItems(node.children, pageContext)