generated from rnentjes/kotlin-server-web-empty
Add new test for complex checkbox list parsing, update parser to reset checkboxList correctly, and bump version to 1.0.11
This commit is contained in:
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "nl.astraeus"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -20,7 +20,7 @@ fun markdown(text: String): List<MarkdownPart> {
|
||||
|
||||
var index = 0
|
||||
val buffer = StringBuilder()
|
||||
val checkboxList = mutableListOf<CheckboxItem>()
|
||||
var checkboxList = mutableListOf<CheckboxItem>()
|
||||
|
||||
fun parseBuffer() {
|
||||
if (buffer.isNotBlank()) {
|
||||
@@ -59,7 +59,7 @@ fun markdown(text: String): List<MarkdownPart> {
|
||||
addCheckbox(checkboxList, checkboxLine, buffer)
|
||||
}
|
||||
parts.add(MarkdownPart.CheckboxList(checkboxList))
|
||||
checkboxList.clear()
|
||||
checkboxList = mutableListOf()
|
||||
parseBuffer()
|
||||
continue
|
||||
} else if (line.startsWith("- [ ]") || line.startsWith("- [x]")) {
|
||||
|
||||
@@ -156,6 +156,34 @@ class ParseTest {
|
||||
printMarkdownParts(md)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCheckboxList3() {
|
||||
val input = """
|
||||
Dit is een text
|
||||
|
||||
- [ ] Not checked,
|
||||
with some more text here
|
||||
- [x] Checked!
|
||||
- [x] Checked,
|
||||
text it!
|
||||
|
||||
Nog 1:
|
||||
|
||||
|
||||
- [ ] Not checked,
|
||||
with some more text here
|
||||
- [x] Checked!
|
||||
- [x] Checked,
|
||||
text it!
|
||||
|
||||
Meer text
|
||||
""".trimIndent()
|
||||
|
||||
val md = markdown(input)
|
||||
|
||||
printMarkdownParts(md)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testCheckboxListError() {
|
||||
|
||||
Reference in New Issue
Block a user