aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-09-27 18:01:02 +0300
committerGitHub <noreply@github.com>2022-09-27 18:01:02 +0300
commitbf8e7dc36360bb122599de2f175e5d010eb0cf10 (patch)
tree66864c7d774c0a4c76b3b47b7e90c9d7652690ca
parentb671dc6d85bcf200b5771b755c4a6b52262a2bad (diff)
downloaddokka-bf8e7dc36360bb122599de2f175e5d010eb0cf10.tar.gz
dokka-bf8e7dc36360bb122599de2f175e5d010eb0cf10.tar.bz2
dokka-bf8e7dc36360bb122599de2f175e5d010eb0cf10.zip
Fix some extra indentation in code block that is inside list (#2233)
-rw-r--r--plugins/base/src/main/kotlin/parsers/MarkdownParser.kt1
-rw-r--r--plugins/base/src/test/kotlin/model/CommentTest.kt31
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(
"""