From fd4d383c521cb13bd96ebaff9b427968d02de220 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Sat, 10 Jan 2026 12:45:33 +0100 Subject: [PATCH] Extend list parsing to handle multi-line items, improve checkbox list parsing with edge case handling, add unordered/ordered list tests, and update version to 1.0.6. --- build.gradle.kts | 2 +- .../kotlin/nl/astraeus/markdown/parser/Parser.kt | 3 +++ .../nl/astraeus/markdown/parser/ParseTest.kt | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b12e55a..3e54e45 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "nl.astraeus" -version = "1.0.6" +version = "1.0.7" repositories { mavenCentral() diff --git a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt index 14c0878..570c543 100644 --- a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt +++ b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt @@ -182,6 +182,9 @@ fun markdown(text: String): List { } if (type == MarkdownType.CHECKBOX_LIST) { + if (buffer.isNotBlank()) { + addCheckbox(checkboxList, index, buffer) + } parts.add(MarkdownPart.CheckboxList(checkboxList)) } else { parseBuffer() diff --git a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt index d870014..621fe97 100644 --- a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt +++ b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt @@ -105,6 +105,22 @@ class ParseTest { printMarkdownParts(md) } + @Test + fun testCheckboxList2() { + val input = """ + # Todo + + - [ ] Handle multi line lists correctly; + as long as there is no empty line the text is appended to last item in the list + - [x] Autolinks, text between < > will be parsed as a generic link. It's up + to the using application what to do with it.""".trimIndent() + + val md = markdown(input) + + printMarkdownParts(md) + } + + @Test fun testCheckboxListError() { val input = """