From 850f66affd41faa3dc2e6cf139b3a24b6b520800 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Sat, 10 Jan 2026 14:39:14 +0100 Subject: [PATCH] Extend parser to support `#.` as an ordered list identifier, add alternative list type tests, and update version to 1.0.9. --- build.gradle.kts | 4 +-- .../nl/astraeus/markdown/parser/Parser.kt | 8 +++-- .../nl/astraeus/markdown/parser/ParseTest.kt | 36 +++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6bdfac2..b62d012 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "nl.astraeus" -version = "1.0.8" +version = "1.0.9" repositories { mavenCentral() @@ -66,7 +66,7 @@ signing { } mavenPublishing { - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true) signAllPublications() diff --git a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt index 8b853ef..44905ff 100644 --- a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt +++ b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Parser.kt @@ -40,7 +40,11 @@ fun markdown(text: String): List { if (line.isBlank()) { parseBuffer() continue - } else if (line.startsWith("${listIndex++}.") || line.startsWith("-.")) { + } else if ( + line.startsWith("${listIndex++}.") + || line.startsWith("-.") + || line.startsWith("#.") + ) { buffer.append("\n") buffer.append(line.substring(2)) } else { @@ -124,7 +128,7 @@ fun markdown(text: String): List { continue } - line.startsWith("1.") || line.startsWith("-.") -> { + line.startsWith("1.") || line.startsWith("-.") || line.startsWith("#.") -> { parseBuffer() type = MarkdownType.ORDERED_LIST listIndex = 2 diff --git a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt index 621fe97..0822ae8 100644 --- a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt +++ b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt @@ -68,6 +68,24 @@ class ParseTest { printMarkdownParts(md) } + @Test + fun testUnorderedListAlternative() { + val input = """ + Dit is een text + + * First + More text + * Second + More text + + Another paragraph + """.trimIndent() + + val md = markdown(input) + + printMarkdownParts(md) + } + @Test fun testOrderedList() { val input = """ @@ -86,6 +104,24 @@ class ParseTest { printMarkdownParts(md) } + @Test + fun testOrderedListAlternative() { + val input = """ + Dit is een text + + #.First + More text + #.Second + More text + + Another paragraph + """.trimIndent() + + val md = markdown(input) + + printMarkdownParts(md) + } + @Test fun testCheckboxList() { val input = """