aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt5
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt10
3 files changed, 15 insertions, 2 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index d6d6f17c..096afd40 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -123,7 +123,7 @@ enum class ContentKind : Kind {
}
enum class TextStyle : Style {
- Bold, Italic, Strong, Strikethrough, Paragraph
+ Bold, Italic, Strong, Strikethrough, Paragraph, Block
}
interface HTMLMetadata: Extra {
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)