diff options
author | Dmitry Jemerov <intelliyole@gmail.com> | 2016-01-12 13:53:18 +0100 |
---|---|---|
committer | Dmitry Jemerov <intelliyole@gmail.com> | 2016-01-12 13:53:18 +0100 |
commit | ebdb4d43516a744bbc38f1dee2752e649c26f95d (patch) | |
tree | 5b285c29c476111cf0eb4baa82f00806ad37dfe6 /core/src/main/kotlin/Kotlin/ContentBuilder.kt | |
parent | 628356d63443b11ff2221707c54a397f548d38a4 (diff) | |
parent | fc0f3f7574198851be009dd62c720b8372344c95 (diff) | |
download | dokka-ebdb4d43516a744bbc38f1dee2752e649c26f95d.tar.gz dokka-ebdb4d43516a744bbc38f1dee2752e649c26f95d.tar.bz2 dokka-ebdb4d43516a744bbc38f1dee2752e649c26f95d.zip |
Merge pull request #48 from ingokegel/master
@Suppress("NOT_DOCUMENTED"), fix for linking to targets with underscores, gradle plugin improvements
Diffstat (limited to 'core/src/main/kotlin/Kotlin/ContentBuilder.kt')
-rw-r--r-- | core/src/main/kotlin/Kotlin/ContentBuilder.kt | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt index e4ed3962..ea07acbc 100644 --- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt +++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt @@ -48,27 +48,27 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (Stri MarkdownElementTypes.PARAGRAPH -> appendNodeWithChildren(ContentParagraph()) MarkdownElementTypes.INLINE_LINK -> { - val label = node.child(MarkdownElementTypes.LINK_TEXT)?.child(MarkdownTokenTypes.TEXT) + val labelText = node.child(MarkdownElementTypes.LINK_TEXT)?.getLabelText() val destination = node.child(MarkdownElementTypes.LINK_DESTINATION) - if (label != null) { + if (labelText != null) { if (destination != null) { val link = ContentExternalLink(destination.text) - link.append(ContentText(label.text)) + link.append(ContentText(labelText)) parent.append(link) } else { - val link = ContentExternalLink(label.text) - link.append(ContentText(label.text)) + val link = ContentExternalLink(labelText) + link.append(ContentText(labelText)) parent.append(link) } } } MarkdownElementTypes.SHORT_REFERENCE_LINK, MarkdownElementTypes.FULL_REFERENCE_LINK -> { - val label = node.child(MarkdownElementTypes.LINK_LABEL)?.child(MarkdownTokenTypes.TEXT) - if (label != null) { - val link = linkResolver(label.text) - val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.child(MarkdownTokenTypes.TEXT) - link.append(ContentText(linkText?.text ?: label.text)) + val labelText = node.child(MarkdownElementTypes.LINK_LABEL)?.getLabelText() + if (labelText != null) { + val link = linkResolver(labelText) + val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.getLabelText() + link.append(ContentText(linkText ?: labelText)) parent.append(link) } } @@ -127,6 +127,8 @@ 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 keepWhitespace(node: ContentNode) = node is ContentParagraph || node is ContentSection fun buildInlineContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) { |