From 9a1015d6b5232d9185ea44ccd5197f5cb3d3c4f7 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Wed, 7 Aug 2024 16:45:49 +0200 Subject: [PATCH] Specify type lambda parameter in `Elements#filter` method It was `Element` when jsoup was `1.11.3` --- .../src/main/kotlin/org/wordpress/aztec/source/Format.kt | 9 ++++++--- .../kotlin/org/wordpress/aztec/util/CleaningUtils.kt | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt index 3ce74a33f..76ed497b5 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt @@ -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 @@ -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") diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt b/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt index 9ae74ebe9..ff37acfb8 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt @@ -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 { @@ -10,12 +11,12 @@ object CleaningUtils { fun cleanNestedBoldTags(doc: Document) { // clean all nested 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 tags that have some text in them doc.select("b > b") - .filter { it.hasText() } + .filter { element: Element -> element.hasText() } .forEach { it.unwrap() } } @@ -25,4 +26,4 @@ object CleaningUtils { cleanNestedBoldTags(doc) return doc.html() } -} \ No newline at end of file +}