Add support for checkbox lists, indented code blocks, and escaped characters. Extend tests for new Markdown features. Update project version to 1.0.4.

This commit is contained in:
2026-01-07 14:56:58 +01:00
parent 6d7d05a0d4
commit ab2572d95d
14 changed files with 242 additions and 12 deletions

View File

@@ -34,6 +34,38 @@ class ParseTest {
printMarkdownParts(md)
}
@Test
fun testIndentedCode() {
val input = """
Dit is een text
Code block
Code block
Meer text
""".trimIndent()
val md = markdown(input)
printMarkdownParts(md)
}
@Test
fun testCheckboxList() {
val input = """
Dit is een text
- [ ] Not checked
- [x] Checked
Meer text
""".trimIndent()
val md = markdown(input)
printMarkdownParts(md)
}
private fun printMarkdownParts(md: List<MarkdownPart>) {
for (part in md) {
if (part is MarkdownPart.Paragraph) {

View File

@@ -19,6 +19,31 @@ class TestParagraph {
assertTrue(result.parts[2] is MarkdownPart.ParagraphPart.Text)
}
@Test
fun testCode() {
val input = "Text `code` Text"
val result = parseParagraph(input)
assertEquals(3, result.parts.size)
assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Text)
assertTrue(result.parts[1] is MarkdownPart.ParagraphPart.InlineCode)
assertTrue(result.parts[2] is MarkdownPart.ParagraphPart.Text)
}
@Test
fun testIndentedCode() {
val input = "Text \n code\n line 2\n\nText"
val result = parseParagraph(input)
assertEquals(3, result.parts.size)
assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Text)
assertTrue(result.parts[1] is MarkdownPart.ParagraphPart.IndentedCode)
assertTrue(result.parts[2] is MarkdownPart.ParagraphPart.Text)
}
@Test
fun testLink() {
@@ -30,4 +55,28 @@ class TestParagraph {
assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Link)
}
@Test
fun testEscaped() {
val input = "Test \\`escaped\\` text"
val result = parseParagraph(input)
assertEquals(1, result.parts.size)
assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Text)
}
@Test
fun testFormatting() {
val input = "test **bold**, *italic*, ***bold and italic***, ~~strikethrough~~, and `code`."
val result = parseParagraph(input)
assertEquals(1, result.parts.size)
assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Text)
}
}