Skip to content

Commit b923bb6

Browse files
vmishenevIgnatBeresnev
authored andcommitted
Fix some extra indentation in code block that is inside list (#2233)
(cherry picked from commit bf8e7dc)
1 parent a7750c6 commit b923bb6

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

plugins/base/src/main/kotlin/parsers/MarkdownParser.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ open class MarkdownParser(
327327
.children
328328
.dropWhile { it.type != MarkdownTokenTypes.CODE_FENCE_CONTENT }
329329
.dropLastWhile { it.type != MarkdownTokenTypes.CODE_FENCE_CONTENT }
330+
.filter { it.type != MarkdownTokenTypes.WHITE_SPACE }
330331
.map {
331332
if (it.type == MarkdownTokenTypes.EOL)
332333
LeafASTNode(MarkdownTokenTypes.HARD_LINE_BREAK, 0, 0)

plugins/base/src/test/kotlin/model/CommentTest.kt

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package model
22

33
import org.jetbrains.dokka.model.DClass
44
import org.jetbrains.dokka.model.DProperty
5-
import org.jetbrains.dokka.model.doc.CodeBlock
6-
import org.jetbrains.dokka.model.doc.CustomTagWrapper
7-
import org.jetbrains.dokka.model.doc.Text
5+
import org.jetbrains.dokka.model.doc.*
6+
import org.jetbrains.dokka.model.doc.Br
87
import org.junit.jupiter.api.Test
98
import utils.*
109

@@ -51,6 +50,32 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme
5150
}
5251
}
5352

53+
@Test
54+
fun codeBlockWithIndentationComment() {
55+
inlineModelTest(
56+
"""
57+
|/**
58+
| * 1.
59+
| * ```
60+
| * line 1
61+
| * line 2
62+
| * ```
63+
| */
64+
|val prop1 = ""
65+
"""
66+
) {
67+
with((this / "comment" / "prop1").cast<DProperty>()) {
68+
name equals "prop1"
69+
with(this.docs().firstOrNull()?.children?.firstOrNull()?.assertNotNull("Code")) {
70+
val codeBlockChildren = ((this?.children?.firstOrNull() as? Li)?.children?.firstOrNull() as? CodeBlock)?.children
71+
(codeBlockChildren?.get(0) as? Text)?.body equals " line 1"
72+
(codeBlockChildren?.get(1) as? Br) notNull "Br"
73+
(codeBlockChildren?.get(2) as? Text)?.body equals " line 2"
74+
}
75+
}
76+
}
77+
}
78+
5479
@Test
5580
fun emptyDoc() {
5681
inlineModelTest(

0 commit comments

Comments
 (0)