Skip to content

Commit

Permalink
Add dd and dl supporval spans = output.getSpans<LeadingMarginSpan>(ou…
Browse files Browse the repository at this point in the history
…tput.length)

                if (spans.isNotEmpty()) {
                    val span = spans.last()
                    val startSpan = output.getSpanStart(span)
                    output.removeSpan(span)
                    output.setSpan(LeadingMarginSpan.Standard(50 * listParents.size), startSpan, output.length, 0)
                }t
  • Loading branch information
cooltey committed Nov 16, 2023
1 parent da89db6 commit 11d6d4f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/org/wikipedia/richtext/CustomHtmlParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ class CustomHtmlParser constructor(private val handler: TagHandler) : TagHandler
} catch (e: Exception) {
L.d("Error on handling list item: $e")
}
} else if ((tag == "dd" || tag == "dl") && output != null) {
try {
handleIndentTag(tag, output, opening)
} catch (e: Exception) {
L.d("Error on handling indent item: $e")
}
}
return false
}
Expand All @@ -245,6 +251,16 @@ class CustomHtmlParser constructor(private val handler: TagHandler) : TagHandler
}
}
}

private fun handleIndentTag(tag: String, output: Editable, opening: Boolean) {
if (tag == "dd") {
if (opening) {
output.insert(output.length, " ")
} else {
output.insert(output.length, "\n")
}
}
}
}

class CustomImageGetter(private val context: Context) : ImageGetter {
Expand Down

0 comments on commit 11d6d4f

Please sign in to comment.