Skip to content

Commit

Permalink
Fix some extra indentation in code block that is inside list (#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Sep 27, 2022
1 parent b671dc6 commit bf8e7dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
Expand Up @@ -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)
Expand Down
31 changes: 28 additions & 3 deletions plugins/base/src/test/kotlin/model/CommentTest.kt
Expand Up @@ -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.*

Expand Down Expand Up @@ -51,6 +50,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(
Expand Down

0 comments on commit bf8e7dc

Please sign in to comment.