From 6d7d05a0d45ddf33e91498a44f261234cb0f7faf Mon Sep 17 00:00:00 2001 From: rnentjes Date: Sun, 14 Dec 2025 15:50:22 +0100 Subject: [PATCH] Update project version to 1.0.3, fix string comparison logic in `test` function, and add a new test for link parsing. --- build.gradle.kts | 2 +- .../kotlin/nl/astraeus/markdown/parser/Paragraph.kt | 2 +- .../nl/astraeus/markdown/parser/TestParagraph.kt | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4943a0d..eab4917 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "nl.astraeus" -version = "1.0.1" +version = "1.0.3" repositories { mavenCentral() diff --git a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Paragraph.kt b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Paragraph.kt index 86cace1..4bb4430 100644 --- a/src/commonMain/kotlin/nl/astraeus/markdown/parser/Paragraph.kt +++ b/src/commonMain/kotlin/nl/astraeus/markdown/parser/Paragraph.kt @@ -115,7 +115,7 @@ private val states = listOf( ) private fun String.test(index: Int, value: String): Boolean { - return this.length > index + value.length && this.substring(index, index + value.length) == value + return this.length >= index + value.length && this.substring(index, index + value.length) == value } fun parseParagraph(text: String): MarkdownPart.Paragraph { diff --git a/src/commonTest/kotlin/nl/astraeus/markdown/parser/TestParagraph.kt b/src/commonTest/kotlin/nl/astraeus/markdown/parser/TestParagraph.kt index 8a6236c..8d3bb5b 100644 --- a/src/commonTest/kotlin/nl/astraeus/markdown/parser/TestParagraph.kt +++ b/src/commonTest/kotlin/nl/astraeus/markdown/parser/TestParagraph.kt @@ -18,4 +18,16 @@ class TestParagraph { assertTrue(result.parts[1] is MarkdownPart.ParagraphPart.Bold) assertTrue(result.parts[2] is MarkdownPart.ParagraphPart.Text) } + + + @Test + fun testLink() { + val input = "[Samsung G8 G80SD](Samsung Odyssey G8 G80SD - OLED-monitor)" + + val result = parseParagraph(input) + + assertEquals(1, result.parts.size) + + assertTrue(result.parts[0] is MarkdownPart.ParagraphPart.Link) + } }