From 57830827b9bc13aad7af6ab899f25b278b248ef7 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Thu, 31 Oct 2019 11:47:41 +0100 Subject: [WIP] commit before rebase --- core/src/main/kotlin/renderers/DefaultRenderer.kt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'core/src/main/kotlin/renderers') diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt index b2647d22..7dab7c5c 100644 --- a/core/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt @@ -16,15 +16,17 @@ abstract class DefaultRenderer(val outputDir: String, val fileWriter: FileWriter protected open fun buildSymbol(parts: List): String = parts.joinToString { it.build() } protected open fun buildBlock(name: String, content: List) = buildHeader(2, name) + content.joinToString("\n") { it.build() } - protected open fun ContentNode.build(): String = - when(this) { - is ContentText -> buildText(this.text) - is ContentComment -> buildComment(this.parts) - is ContentSymbol -> buildSymbol(this.parts) - is ContentCode -> buildCode(this.code) - is ContentBlock -> buildBlock(this.name, this.children) - is ContentLink -> buildLink(this.text, locationProvider.resolve(this.address, this.platforms)) - is ContentGroup -> buildGroup(this.children) + protected open fun ContentNode.build(): String = buildContentNode(this) + + protected open fun buildContentNode(node: ContentNode) = + when(node) { + is ContentText -> buildText(node.text) + is ContentComment -> buildComment(node.parts) + is ContentSymbol -> buildSymbol(node.parts) + is ContentCode -> buildCode(node.code) + is ContentBlock -> buildBlock(node.name, node.children) + is ContentLink -> buildLink(node.text, locationProvider.resolve(node.address, node.platforms)) + is ContentGroup -> buildGroup(node.children) else -> "" } -- cgit