Skip to content

Commit 3996a9b

Browse files
authored
fix: documentation trait handling empty list items (#1175)
1 parent f0df363 commit 3996a9b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class DocumentationPreprocessor : KotlinIntegration {
104104
"li" -> {
105105
// If this list item holds a sublist, then we essentially just want to line break right away and
106106
// render the nested list as normal.
107-
val prefix = if (node.childNode(0).nodeName() == "ul") "\n" else ""
107+
val prefix = if (node.childNodes().firstOrNull()?.nodeName() == "ul") "\n" else ""
108108
builder.append("$listPrefix+ $prefix")
109109
}
110110
"ul", "ol" -> {

codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessorTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ class DocumentationPreprocessorTest {
9494
inputTest(input, expected)
9595
}
9696

97+
@Test
98+
fun `it renders lists with empty list items`() {
99+
val input = "<p>an unordered list with empty list items:</p><ul><li></li><li></li></ul>"
100+
val expected = """
101+
an unordered list with empty list items:
102+
+
103+
+
104+
""".trimIndent()
105+
inputTest(input, expected)
106+
}
107+
97108
@Test
98109
fun `it renders basic formatters`() {
99110
val input = "<strong>bold text</strong><br/><em>italic text</em>"

0 commit comments

Comments
 (0)