diff options
author | Szymon Świstun <sswistun@virtuslab.com> | 2019-12-16 15:25:33 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-01-08 10:45:08 +0100 |
commit | 254e2a2dfae4f8d5eea26cdc4728b4fdb27cfee0 (patch) | |
tree | 15c3b5c22e4ad266c177cff8b499057e16ebade2 /core/src/main/kotlin | |
parent | c4c992a2050f96871ea44cddbf39367f568bf544 (diff) | |
download | dokka-254e2a2dfae4f8d5eea26cdc4728b4fdb27cfee0.tar.gz dokka-254e2a2dfae4f8d5eea26cdc4728b4fdb27cfee0.tar.bz2 dokka-254e2a2dfae4f8d5eea26cdc4728b4fdb27cfee0.zip |
change in list building logic
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/renderers/HtmlRenderer.kt | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/src/main/kotlin/renderers/HtmlRenderer.kt b/core/src/main/kotlin/renderers/HtmlRenderer.kt index e9f2801e..961e942c 100644 --- a/core/src/main/kotlin/renderers/HtmlRenderer.kt +++ b/core/src/main/kotlin/renderers/HtmlRenderer.kt @@ -21,13 +21,16 @@ open class HtmlRenderer( protected open fun buildListItems(items: List<ContentNode>, pageContext: PageNode) = items.joinToString("") { - if (it is ContentText) "<li>\n${it.build(pageContext)}\n</li>\n" else buildList( - it as ContentList, + if (it is ContentList) buildList( + it, pageContext - ) + ) else "<li>\n${it.build(pageContext)}\n</li>\n" } - override fun buildResource(node: ContentEmbeddedResource, pageContext: PageNode): String { // TODO: extension point there + override fun buildResource( + node: ContentEmbeddedResource, + pageContext: PageNode + ): String { // TODO: extension point there val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg") return if (File(node.address).extension.toLowerCase() in imageExtensions) { val imgAttrs = node.extras.filterIsInstance<HTMLSimpleAttr>().joinAttr() @@ -56,7 +59,8 @@ open class HtmlRenderer( |</table>""".trimMargin() } - protected open fun ContentGroup.buildTableRow(pageContext: PageNode) = children.joinToString("</td>\n<td>\n") { it.build(pageContext) } + protected open fun ContentGroup.buildTableRow(pageContext: PageNode) = + children.joinToString("</td>\n<td>\n") { it.build(pageContext) } override fun buildHeader(level: Int, text: String): String = "<h$level>$text</h$level>\n" @@ -64,7 +68,8 @@ open class HtmlRenderer( override fun buildLink(text: String, address: String): String = "<a href=\"$address\">$text</a>" - override fun buildCode(code: List<ContentNode>, language: String, pageContext: PageNode): String = buildNewLine() + "<code>${code.joinToString("") { (it as ContentText).text + buildNewLine() }}</code>" + override fun buildCode(code: List<ContentNode>, language: String, pageContext: PageNode): String = + buildNewLine() + "<code>${code.joinToString("") { (it as ContentText).text + buildNewLine() }}</code>" override fun buildText(textNode: ContentText): String = super.buildText(textNode).htmlEscape() |