This commit is contained in:
Simon Ogorodnik
2018-06-06 20:56:37 +03:00
parent bfa5afa564
commit 9283089397
@@ -133,8 +133,7 @@ object KDocRenderer {
val subjectName = tag.getSubjectName() val subjectName = tag.getSubjectName()
if (subjectName != null) { if (subjectName != null) {
DocumentationManagerUtil.createHyperlink(this, subjectName, subjectName, false) DocumentationManagerUtil.createHyperlink(this, subjectName, subjectName, false)
} } else {
else {
append(tag.getContent()) append(tag.getContent())
} }
if (index < seeTags.size - 1) { if (index < seeTags.size - 1) {
@@ -173,8 +172,7 @@ object KDocRenderer {
maybeSingleParagraph.children.joinToString("") { maybeSingleParagraph.children.joinToString("") {
if (it.text == "\n") " " else it.toHtml() if (it.text == "\n") " " else it.toHtml()
} }
} } else {
else {
markdownNode.toHtml() markdownNode.toHtml()
} }
} }
@@ -247,14 +245,13 @@ object KDocRenderer {
MarkdownElementTypes.FULL_REFERENCE_LINK -> { MarkdownElementTypes.FULL_REFERENCE_LINK -> {
val linkLabelNode = node.child(MarkdownElementTypes.LINK_LABEL) val linkLabelNode = node.child(MarkdownElementTypes.LINK_LABEL)
val linkLabelContent = linkLabelNode?.children val linkLabelContent = linkLabelNode?.children
?.dropWhile { it.type == MarkdownTokenTypes.LBRACKET } ?.dropWhile { it.type == MarkdownTokenTypes.LBRACKET }
?.dropLastWhile { it.type == MarkdownTokenTypes.RBRACKET } ?.dropLastWhile { it.type == MarkdownTokenTypes.RBRACKET }
if (linkLabelContent != null) { if (linkLabelContent != null) {
val label = linkLabelContent.joinToString(separator = "") { it.text } val label = linkLabelContent.joinToString(separator = "") { it.text }
val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.toHtml() ?: label val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.toHtml() ?: label
DocumentationManagerUtil.createHyperlink(sb, label, linkText, true) DocumentationManagerUtil.createHyperlink(sb, label, linkText, true)
} } else {
else {
sb.append(node.text) sb.append(node.text)
} }
} }
@@ -263,8 +260,7 @@ object KDocRenderer {
val destination = node.child(MarkdownElementTypes.LINK_DESTINATION)?.text val destination = node.child(MarkdownElementTypes.LINK_DESTINATION)?.text
if (label != null && destination != null) { if (label != null && destination != null) {
sb.append("<a href=\"$destination\">$label</a>") sb.append("<a href=\"$destination\">$label</a>")
} } else {
else {
sb.append(node.text) sb.append(node.text)
} }
} }
@@ -290,8 +286,7 @@ object KDocRenderer {
val parentType = node.parent?.type val parentType = node.parent?.type
if (parentType == MarkdownElementTypes.CODE_BLOCK || parentType == MarkdownElementTypes.CODE_FENCE) { if (parentType == MarkdownElementTypes.CODE_BLOCK || parentType == MarkdownElementTypes.CODE_FENCE) {
sb.append("\n") sb.append("\n")
} } else {
else {
sb.append(" ") sb.append(" ")
} }
} }