Fix toPlainText where <ol start='n'> tags appear (#5044)
This commit is contained in:
parent
871ba9652c
commit
62b377dcb8
2 changed files with 31 additions and 2 deletions
|
|
@ -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("• ")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue