You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,11 @@ class DocumentationPreprocessor : KotlinIntegration {
39
39
val parsed = parseClean(doc)
40
40
41
41
val renderer =MarkdownRenderer()
42
-
parsed.body().traverse(renderer)
42
+
try {
43
+
parsed.body().traverse(renderer)
44
+
} catch (e:IndexOutOfBoundsException) {
45
+
throwException("These are the docs causing issues: \n"+ doc)
46
+
}
43
47
return renderer.text()
44
48
}
45
49
@@ -102,9 +106,11 @@ class DocumentationPreprocessor : KotlinIntegration {
102
106
}
103
107
}
104
108
"li"-> {
109
+
val childNode =if (node.childNodes().isNotEmpty()) node.childNode(0) elsenull
110
+
105
111
// If this list item holds a sublist, then we essentially just want to line break right away and
106
112
// render the nested list as normal.
107
-
val prefix =if (node.childNode(0).nodeName() =="ul") "\n"else""
113
+
val prefix =if (childNode?.nodeName() =="ul") "\n"else""
Copy file name to clipboardExpand all lines: codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessorTest.kt
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -94,6 +94,17 @@ class DocumentationPreprocessorTest {
94
94
inputTest(input, expected)
95
95
}
96
96
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
+
97
108
@Test
98
109
fun`it renders basic formatters`() {
99
110
val input ="<strong>bold text</strong><br/><em>italic text</em>"
0 commit comments