Skip to content

KDoc parser: Missing space between consecutive composite leaf nodes in markdown parser #1975

@msink

Description

@msink

Describe the bug
/** Rotates paths by `amount` **radians** around (`x`, `y`). */
rendered
Rotates paths by `amount`**radians** around (`x`, `y`).

Expected behaviour
Rotates paths by `amount` **radians** around (`x`, `y`).

To Reproduce
Actual bug is in KDoc parser, to reproduce - add test below in ParserTest.kt
Actually passes with Text(" ") commented-out, while should with uncommented.

    @Test
    fun `Code and bold`() {
        val kdoc = "Rotates paths by `amount` **radians** around (`x`, `y`)."
        val expectedDocumentationNode = DocumentationNode(
            listOf(
                Description(
                    CustomDocTag(
                        listOf(
                            P(
                                listOf(
                                    Text("Rotates paths by "),
                                    CodeInline(listOf(Text("amount"))),
                                    //Text(" "),
                                    B(listOf(Text("radians"))),
                                    Text(" around ("),
                                    CodeInline(listOf(Text("x"))),
                                    Text(", "),
                                    CodeInline(listOf(Text("y"))),
                                    Text(")."),
                                )
                            )
                        ), name = MarkdownElementTypes.MARKDOWN_FILE.name
                    )
                )
            )
        )
        executeTest(kdoc, expectedDocumentationNode)
    }

    @Test
    fun `Code with backticks`() {
        val kdoc = "` `` ` ` ``` `"
        val expectedDocumentationNode = DocumentationNode(
            listOf(
                Description(
                    CustomDocTag(
                        listOf(
                            P(
                                listOf(
                                    CodeInline(listOf(Text("`` "))),
                                    //Text(" "),
                                    CodeInline(listOf(Text("``` "))),
                                )
                            )
                        ), name = MarkdownElementTypes.MARKDOWN_FILE.name
                    )
                )
            )
        )
        executeTest(kdoc, expectedDocumentationNode)
    }

Traced - space is removed in

private fun List<ASTNode>.mergeLeafASTNodes(): List<ASTNode> {

On entry it is here, on exit - dropped.

Why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions