From a74b3c1cabde1dad3e91f804a89a90398dba1932 Mon Sep 17 00:00:00 2001 From: Fred Sladkey Date: Mon, 30 Aug 2021 11:09:49 -0400 Subject: Don't force @literal in javadoc to be surrounded by code tag (#2089) * Don't force @literal in javadoc to be surrounded by code tag * Enclose in tag and add test for angle brackets --- .../src/main/kotlin/translators/psi/parsers/JavadocParser.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index 8583edf7..8bc950b7 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -333,8 +333,8 @@ class JavadocParser( when (tag.name) { "link", "linkplain" -> tag.referenceElement() ?.toDocumentationLinkString(tag.dataElements.filterIsInstance()) - "code", "literal" -> "${tag.dataElements.joinToString("") { it.stringifyElementAsText(keepFormatting = true) - .toString() }.htmlEscape()}" + "code" -> "${dataElementsAsText(tag)}" + "literal" -> "${dataElementsAsText(tag)}" "index" -> "${tag.children.filterIsInstance().joinToString { it.text }}" "inheritDoc" -> inheritDocResolver.resolveFromContext(context) ?.fold(ParsingResult(javadocTag)) { result, e -> @@ -343,6 +343,11 @@ class JavadocParser( else -> tag.text } + private fun dataElementsAsText(tag: PsiInlineDocTag) = + tag.dataElements.joinToString("") { + it.stringifyElementAsText(keepFormatting = true).toString() + }.htmlEscape() + private fun createLink(element: Element, children: List): DocTag { return when { element.hasAttr("docref") -> -- cgit