diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt | 3 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt | 47 |
2 files changed, 50 insertions, 0 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 fd8a49c8..13d17f52 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -421,6 +421,9 @@ class JavadocParser( parsed } } + "h1" -> ifChildrenPresent { H1(children) } + "h2" -> ifChildrenPresent { H2(children) } + "h3" -> ifChildrenPresent { H3(children) } else -> listOf(Text(body = element.ownText())) } } diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt index c066075a..4f37923b 100644 --- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt +++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt @@ -349,4 +349,51 @@ class JavadocParserTest : BaseAbstractTest() { } } } + + @Test + fun `header tags are handled properly`() { + val source = """ + |/src/main/kotlin/test/Test.java + |package example + | + | /** + | * An example of using the header tags + | * <h1>A header</h1> + | * <h2>A second level header</h2> + | * <h3>A third level header</h3> + | */ + | 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(Text("An example of using the header tags "))), + H1( + listOf( + Text("A header") + ) + ), + H2( + listOf( + Text("A second level header") + ) + ), + H3( + listOf( + Text("A third level header") + ) + ) + ), + root.children + ) + } + } + } } |