Skip to content

Commit

Permalink
Specify type lambda parameter in Elements#filter method
Browse files Browse the repository at this point in the history
It was `Element` when jsoup was `1.11.3`
  • Loading branch information
wzieba committed Aug 7, 2024
1 parent 93d032c commit 9a1015d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.text.SpannableStringBuilder
import android.text.TextUtils
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import org.wordpress.aztec.spans.AztecQuoteSpan
import org.wordpress.aztec.spans.AztecVisualLinebreak
import org.wordpress.aztec.spans.EndOfParagraphMarker
Expand All @@ -30,9 +32,10 @@ object Format {
CleaningUtils.cleanNestedBoldTags(doc)
if (isCalypsoFormat) {
// remove empty span tags
doc.select("*")
.filter { !it.hasText() && it.tagName() == "span" && it.childNodes().size == 0 }
.forEach { it.remove() }
val select: Elements = doc.select("*")
select.filter { element: Element ->
!element.hasText() && element.tagName() == "span" && element.childNodes().size == 0
}.forEach { it.remove() }

html = replaceAll(doc.body().html(), iframePlaceholder, "iframe")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.wordpress.aztec.util

import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.parser.Parser

object CleaningUtils {
Expand All @@ -10,12 +11,12 @@ object CleaningUtils {
fun cleanNestedBoldTags(doc: Document) {
// clean all nested <b> tags that don't contain anything
doc.select("b > b")
.filter { !it.hasText() }
.filter { element: Element -> !element.hasText() }
.forEach { it.remove() }

// unwrap text in between nested <b> tags that have some text in them
doc.select("b > b")
.filter { it.hasText() }
.filter { element: Element -> element.hasText() }
.forEach { it.unwrap() }
}

Expand All @@ -25,4 +26,4 @@ object CleaningUtils {
cleanNestedBoldTags(doc)
return doc.html()
}
}
}

0 comments on commit 9a1015d

Please sign in to comment.