diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-09-27 13:43:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 13:43:07 +0300 |
commit | 1b1b5e70f9220a49801729aff5e43883014fe1d4 (patch) | |
tree | ab28f45bd4641df05698f82eb07555094230a287 | |
parent | bcdb4366a55a25ddd1314cbf79ab27a8006c160c (diff) | |
download | dokka-1b1b5e70f9220a49801729aff5e43883014fe1d4.tar.gz dokka-1b1b5e70f9220a49801729aff5e43883014fe1d4.tar.bz2 dokka-1b1b5e70f9220a49801729aff5e43883014fe1d4.zip |
Fix `img` tag in javadoc (#2166)
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt | 5 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt | 43 |
2 files changed, 44 insertions, 4 deletions
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 ecf31541..d74a1ca4 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -377,6 +377,11 @@ class JavadocParser( "strong" -> ifChildrenPresent { Strong(children) } "index" -> listOf(Index(children)) "i" -> ifChildrenPresent { I(children) } + "img" -> listOf( + Img( + children, + element.attributes().associate { (if (it.key == "src") "href" else it.key) to it.value }) + ) "em" -> listOf(Em(children)) "code" -> ifChildrenPresent { if(keepFormatting) CodeBlock(children) else CodeInline(children) } "pre" -> if(children.size == 1) { diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt index bdb1af86..e6e1e105 100644 --- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt +++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt @@ -4,11 +4,8 @@ import com.jetbrains.rd.util.first import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.doc.CodeBlock -import org.jetbrains.dokka.model.doc.CodeInline +import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.model.doc.P -import org.jetbrains.dokka.model.doc.Pre -import org.jetbrains.dokka.model.doc.Text import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import utils.* @@ -214,4 +211,42 @@ class JavadocParserTest : BaseAbstractTest() { } } } + + @Test + fun `html img tag`() { + val source = """ + |/src/main/kotlin/test/Test.java + |package example + | + | /** + | * <img src="/path/to/img.jpg" alt="Alt text"/> + | */ + | public class Test {} + """.trimIndent() + testInline( + source, + configuration, + ) { + documentablesCreationStage = { modules -> + val docs = modules.first().packages.first().classlikes.single().documentation.first().value + val root = docs.children.first().root + + kotlin.test.assertEquals( + listOf( + P( + children = listOf( + Img( + params = mapOf( + "href" to "/path/to/img.jpg", + "alt" to "Alt text" + ) + ) + ) + ) + ), + root.children + ) + } + } + } } |