From f3973480c0b03c9f28f05b5a4cf61bf3de3597bd Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 3 Mar 2015 19:51:43 +0100 Subject: support links with custom labels --- src/Java/JavaDocumentationBuilder.kt | 3 ++- src/Kotlin/ContentBuilder.kt | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index c2a15a45..00a7f3ac 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -126,7 +126,8 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, val valueElement = tag.linkElement() val linkSignature = resolveLink(valueElement) if (linkSignature != null) { - val link = "${valueElement!!.getText().htmlEscape()}" + val labelText = tag.getDataElements().firstOrNull { it is PsiDocToken }?.getText() ?: valueElement!!.getText() + val link = "${labelText.htmlEscape()}" if (tag.getName() == "link") "$link" else link } else if (valueElement != null) { diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 4081dc6e..0aa80df0 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -74,11 +74,13 @@ public fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver } } } - MarkdownElementTypes.SHORT_REFERENCE_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) - link.append(ContentText(label.text)) + val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.child(MarkdownTokenTypes.TEXT) + link.append(ContentText(linkText?.text ?: label.text)) parent.append(link) } } -- cgit