aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/markdown/ParserTest.kt55
1 files changed, 54 insertions, 1 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt
index 8e2d71eb..bcca27c4 100644
--- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt
+++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt
@@ -1573,7 +1573,60 @@ class ParserTest : KDocTest() {
P(listOf(Text(" sdsdsds sdd"))),
P(listOf(Text(" eweww ")))
)
- print(expectedDocumentationNode)
+ assertEquals(actualDocumentationNode, expectedDocumentationNode)
+ }
+
+ @Test // exists due to #3231
+ fun `should ignore the leading whitespace in header in-between the hash symbol and header text`() {
+ val markdown = """
+ | # first header
+ | ## second header
+ | ### third header
+ """.trimMargin()
+ val actualDocumentationNode = parseMarkdownToDocNode(markdown).children
+ val expectedDocumentationNode = listOf(
+ H1(listOf(Text("first header"))),
+ H2(listOf(Text("second header"))),
+ H3(listOf(Text("third header"))),
+ )
+ assertEquals(actualDocumentationNode, expectedDocumentationNode)
+ }
+
+ @Test // exists due to #3231
+ fun `should ignore trailing whitespace in header`() {
+ val markdown = """
+ | # first header
+ | ## second header
+ | ### third header
+ """.trimMargin()
+ val actualDocumentationNode = parseMarkdownToDocNode(markdown).children
+ val expectedDocumentationNode = listOf(
+ H1(listOf(Text("first header"))),
+ H2(listOf(Text("second header"))),
+ H3(listOf(Text("third header"))),
+ )
+ assertEquals(actualDocumentationNode, expectedDocumentationNode)
+ }
+
+ @Test // exists due to #3231
+ fun `should ignore leading and trailing whitespace in header, but not whitespace in the middle`() {
+ val markdown = """
+ | # first header
+ | ## second ~~header~~ in a **long** sentence ending with whitespaces
+ | ### third header
+ """.trimMargin()
+ val actualDocumentationNode = parseMarkdownToDocNode(markdown).children
+ val expectedDocumentationNode = listOf(
+ H1(listOf(Text("first header"))),
+ H2(listOf(
+ Text("second "),
+ Strikethrough(listOf(Text("header"))),
+ Text(" in a "),
+ B(listOf(Text("long"))),
+ Text(" sentence ending with whitespaces")
+ )),
+ H3(listOf(Text("third header"))),
+ )
assertEquals(actualDocumentationNode, expectedDocumentationNode)
}
}