Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ class DocumentationPreprocessor : KotlinIntegration {
.applyWithin("<pre>", "</pre>", String::escapeHtml)
val parsed = Jsoup.parse(sanitized)

fun Node.emptyOrBlank(): Boolean = when {
this is TextNode -> isBlank
else -> childNodes().all { it.emptyOrBlank() }
}

parsed.body().filterDescendants(
// Jsoup will preserve newlines between elements as blank text nodes. These have zero bearing on the content
// of the document to begin with and only serve to complicate traversal.
{ it is TextNode && it.isBlank },
// Some docs contain empty definition terms, which we render as section headers. An empty section header
// (literal "## \n" is invalid markdown according to dokka.
{ it.nodeName() == "dt" && it.childNodes().isEmpty() },
{ it.nodeName() == "dt" && it.emptyOrBlank() },
)

return parsed
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kotlinx-serialization-version = "1.7.3"
docker-java-version = "3.4.0"
ktor-version = "3.2.3"
kaml-version = "0.55.0"
jsoup-version = "1.19.1"
jsoup-version = "1.21.1"

[libraries]
aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" }
Expand Down
Loading