Fix toPlainText where <ol start='n'> tags appear (#5044)

This commit is contained in:
Jorge Martin Espinosa 2025-07-18 13:23:26 +02:00 committed by GitHub
parent 871ba9652c
commit 62b377dcb8
2 changed files with 31 additions and 2 deletions

View file

@ -57,10 +57,16 @@ private class PlainTextNodeVisitor : NodeVisitor {
if (node is TextNode && node.text().isNotBlank()) {
builder.append(node.text())
} else if (node is Element && node.tagName() == "li") {
val index = node.elementSiblingIndex()
val index = node.elementSiblingIndex() + 1
val isOrdered = node.parent()?.nodeName()?.lowercase() == "ol"
if (isOrdered) {
builder.append("${index + 1}. ")
val startIndex = node.parent()?.attr("start")?.toIntOrNull()
val actualIndex = if (startIndex != null) {
startIndex + index - 1
} else {
index
}
builder.append("$actualIndex. ")
} else {
builder.append("")
}