From ec2bf8a57c744008c30d03c4aec0921a091faa81 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Mon, 9 Aug 2021 12:32:08 +0300 Subject: Keep formatting within code inline (#2060) --- .../base/src/main/kotlin/parsers/MarkdownParser.kt | 3 +- .../kotlin/content/ContentInDescriptionTest.kt | 33 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt index 4787c091..75617e0c 100644 --- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt +++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt @@ -305,7 +305,8 @@ open class MarkdownParser( node.type, children = DocTagsFromIElementFactory.getInstance( MarkdownTokenTypes.TEXT, - body = text.substring(node.startOffset + 1, node.endOffset - 1).replace('\n', ' ').trimIndent() + body = text.substring(node.startOffset + 1, node.endOffset - 1).replace('\n', ' ').trimIndent(), + keepFormatting = true ) ) diff --git a/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt b/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt index 1a3bda5e..b44eb651 100644 --- a/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt +++ b/plugins/base/src/test/kotlin/content/ContentInDescriptionTest.kt @@ -2,10 +2,7 @@ package content import junit.framework.Assert.assertEquals import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest -import org.jetbrains.dokka.model.doc.CustomDocTag -import org.jetbrains.dokka.model.doc.Description -import org.jetbrains.dokka.model.doc.P -import org.jetbrains.dokka.model.doc.Text +import org.jetbrains.dokka.model.doc.* import org.junit.jupiter.api.Test import kotlin.test.assertTrue @@ -110,4 +107,32 @@ class ContentInDescriptionTest : BaseAbstractTest() { } } } + + @Test + fun `text surrounded by angle brackets is not removed`() { + testInline( + """ + |/src/main/kotlin/sample/Foo.kt + |package sample + |/** + | * My example `CodeInline` + | * ``` + | * CodeBlock + | * ``` + | */ + |class Foo { + |} + """.trimIndent(), + configuration + ) { + documentablesMergingStage = { module -> + val cls = module.packages.flatMap { it.classlikes }.first { it.name == "Foo" } + val documentation = cls.documentation.values.first() + val docTags = documentation.children.single().root.children + + assertEquals("CodeInline", ((docTags[0].children[1] as CodeInline).children.first() as Text).body) + assertEquals("CodeBlock", ((docTags[1] as CodeBlock).children.first() as Text).body) + } + } + } } \ No newline at end of file -- cgit