Skip to content

Commit 50ca5cf

Browse files
committed
feat: change bullet style depending on the nesting level. fixes #17
1 parent 3056ad6 commit 50ca5cf

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

htmlconverter/src/commonMain/kotlin/be/digitalia/compose/htmlconverter/internal/AnnotatedStringHtmlHandler.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,20 @@ internal class AnnotatedStringHtmlHandler(
261261
listIndexes[currentListLevel - 1]
262262
}
263263
if (itemIndex < 0) {
264-
textWriter.write("")
264+
textWriter.write(getBulletString(currentListLevel))
265265
} else {
266266
textWriter.write(itemIndex.toString())
267267
textWriter.write(". ")
268268
listIndexes[currentListLevel - 1] = itemIndex + 1
269269
}
270270
}
271271

272+
private fun getBulletString(listLevel: Int): String = when (listLevel) {
273+
0, 1 -> ""
274+
2 -> ""
275+
else -> ""
276+
}
277+
272278
private fun handleDefinitionTermStart() {
273279
handleBlockStart(1, false)
274280
}

sample/src/commonMain/kotlin/SampleHtml.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ val SampleHtml
2727
<li>Item 2</li>
2828
</ol>
2929
</li>
30+
<li>A nested unordered list:
31+
<ul>
32+
<li>Item 1</li>
33+
<li>Item 2</li>
34+
</ul>
35+
</li>
3036
</ul>
3137
3238
<dl>

0 commit comments

Comments
 (0)