Skip to content

Commit

Permalink
Merge pull request #446 from MohamedRejeb/1.x
Browse files Browse the repository at this point in the history
Fix Issue on parsing Markdown with code span split between two lines
  • Loading branch information
MohamedRejeb authored Dec 8, 2024
2 parents afe820c + fb15ff4 commit 612f9f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ internal object RichTextStateMarkdownParser : RichTextStateParser<String> {
}

fun onText(text: String) {
val text = text.replace('\n', ' ')

if (text.isEmpty()) return

if (richParagraphList.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,30 @@ class RichTextStateMarkdownParserEncodeTest {
)
}

@Test
fun testEncodeInlineCodeInDifferentLines() {
val markdown =
"""
Hello `World!
Kotlin` MP
""".trimIndent()

val state = RichTextStateMarkdownParser.encode(markdown)

val parsedString = state.toText()

assertEquals(
expected =
"""
Hello World! Kotlin MP
""".trimIndent(),
actual = parsedString,
)

assertEquals(
expected = 1,
actual = state.richParagraphList.size,
)
}

}

0 comments on commit 612f9f7

Please sign in to comment.