Skip to content

Commit

Permalink
Merge pull request #445 from MohamedRejeb/1.x
Browse files Browse the repository at this point in the history
Fix Markdown fails to parse lines with leading spaces
  • Loading branch information
MohamedRejeb authored Dec 8, 2024
2 parents bca753e + 4b57d55 commit afe820c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ internal object RichTextStateMarkdownParser : RichTextStateParser<String> {
newRichSpan.text = "$".repeat(node.endOffset - node.startOffset)
}

if (node.type == GFMTokenTypes.GFM_AUTOLINK) {
if (
node.type == GFMTokenTypes.GFM_AUTOLINK ||
node.type == MarkdownTokenTypes.CODE_LINE
) {
onText(node.getTextInNode(input).toString())
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,24 @@ class RichTextStateMarkdownParserEncodeTest {
assertEquals("Prompt\nEmphasis", state.toText())
}

@Test
fun testEncodeWithLeadingSpaces() {
val markdown = """First line
indented line"""

val state = RichTextStateMarkdownParser.encode(markdown)

val parsedString = state.toText()

assertEquals(
expected = """
First line
indented line
""".trimIndent(),
actual = parsedString
)
}

}

0 comments on commit afe820c

Please sign in to comment.