aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin/ContentBuilder.kt
diff options
context:
space:
mode:
authorAlex Waters <awaters@nextfaze.com>2017-05-01 14:00:31 +0930
committerSimon Ogorodnik <sem-oro@yandex.ru>2017-05-04 14:26:37 +0300
commitc2afb348bb0d3dd60d336aa312b5fcedfb31b966 (patch)
tree7071aebbdb30b82532bcdce545edc27d2d3eb4a5 /core/src/main/kotlin/Kotlin/ContentBuilder.kt
parent54c3c87acfb31afc22afc5f20229384f755b677f (diff)
downloaddokka-c2afb348bb0d3dd60d336aa312b5fcedfb31b966.tar.gz
dokka-c2afb348bb0d3dd60d336aa312b5fcedfb31b966.tar.bz2
dokka-c2afb348bb0d3dd60d336aa312b5fcedfb31b966.zip
Fix Markdown list spacing, ordering, and erroneous new lines
Diffstat (limited to 'core/src/main/kotlin/Kotlin/ContentBuilder.kt')
-rw-r--r--core/src/main/kotlin/Kotlin/ContentBuilder.kt5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt
index c124821e..a244a48e 100644
--- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt
@@ -96,7 +96,9 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (Stri
}
}
MarkdownTokenTypes.EOL -> {
- if (keepEol(nodeStack.peek()) && node.parent?.children?.last() != node) {
+ if ((keepEol(nodeStack.peek()) && node.parent?.children?.last() != node) ||
+ // Keep extra blank lines when processing lists (affects Markdown formatting)
+ (processingList(nodeStack.peek()) && node.previous?.type == MarkdownTokenTypes.EOL)) {
parent.append(ContentText(node.text))
}
}
@@ -156,6 +158,7 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (Stri
private fun MarkdownNode.getLabelText() = children.filter { it.type == MarkdownTokenTypes.TEXT || it.type == MarkdownTokenTypes.EMPH }.joinToString("") { it.text }
private fun keepEol(node: ContentNode) = node is ContentParagraph || node is ContentSection || node is ContentBlockCode
+private fun processingList(node: ContentNode) = node is ContentOrderedList || node is ContentUnorderedList
fun buildInlineContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) {
val inlineContent = tree.children.singleOrNull { it.type == MarkdownElementTypes.PARAGRAPH }?.children ?: listOf(tree)