diff options
-rw-r--r-- | plugins/base/src/main/kotlin/parsers/MarkdownParser.kt | 1 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/model/CommentTest.kt | 31 |
2 files changed, 29 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt index a1648b16..d49e7c7a 100644 --- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt +++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt @@ -327,6 +327,7 @@ open class MarkdownParser( .children .dropWhile { it.type != MarkdownTokenTypes.CODE_FENCE_CONTENT } .dropLastWhile { it.type != MarkdownTokenTypes.CODE_FENCE_CONTENT } + .filter { it.type != MarkdownTokenTypes.WHITE_SPACE } .map { if (it.type == MarkdownTokenTypes.EOL) LeafASTNode(MarkdownTokenTypes.HARD_LINE_BREAK, 0, 0) diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index c511a3de..7f2151bc 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -2,9 +2,8 @@ package model import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.DProperty -import org.jetbrains.dokka.model.doc.CodeBlock -import org.jetbrains.dokka.model.doc.CustomTagWrapper -import org.jetbrains.dokka.model.doc.Text +import org.jetbrains.dokka.model.doc.* +import org.jetbrains.dokka.model.doc.Br import org.junit.jupiter.api.Test import utils.* @@ -52,6 +51,32 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme } @Test + fun codeBlockWithIndentationComment() { + inlineModelTest( + """ + |/** + | * 1. + | * ``` + | * line 1 + | * line 2 + | * ``` + | */ + |val prop1 = "" + """ + ) { + with((this / "comment" / "prop1").cast<DProperty>()) { + name equals "prop1" + with(this.docs().firstOrNull()?.children?.firstOrNull()?.assertNotNull("Code")) { + val codeBlockChildren = ((this?.children?.firstOrNull() as? Li)?.children?.firstOrNull() as? CodeBlock)?.children + (codeBlockChildren?.get(0) as? Text)?.body equals " line 1" + (codeBlockChildren?.get(1) as? Br) notNull "Br" + (codeBlockChildren?.get(2) as? Text)?.body equals " line 2" + } + } + } + } + + @Test fun emptyDoc() { inlineModelTest( """ |