Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some extra indentation in code block that is inside list #2233

Merged
merged 4 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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