Makes library multiplatform (#27)

* Replaces JSoup by Ksoup
This commit is contained in:
julien Lengrand-Lambert
2025-06-08 14:16:48 +02:00
committed by GitHub
parent 5372fab21c
commit 3c0eed60a7
4 changed files with 23 additions and 15 deletions

View File

@@ -12,7 +12,9 @@ repositories {
}
dependencies {
implementation("org.jsoup:jsoup:1.20.1")
implementation("com.fleeksoft.ksoup:ksoup:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-network:0.2.4")
implementation(project(":opengraphkt"))
testImplementation(kotlin("test"))
}

View File

@@ -1,6 +1,6 @@
package fr.lengrand.opengraphkt
import org.jsoup.Jsoup
import com.fleeksoft.ksoup.Ksoup
import java.io.File
import java.net.URI
@@ -25,7 +25,7 @@ fun main() {
println("\nExample 2: Parsing from File")
try {
val resourceUrl = object {}.javaClass.getResource("/example.html")
val resourceFile = File(resourceUrl.toURI())
val resourceFile = File(resourceUrl!!.toURI())
// Parse the file
val openGraphData = parser.parse(resourceFile)
@@ -66,7 +66,7 @@ fun main() {
// Example 4: Parse Open Graph data from a Jsoup Document
println("\nExample 4: Parsing from JSoup Document")
val doc = Jsoup.parse(html)
val doc = Ksoup.parse(html)
val openGraphDataDoc = parser.parse(doc)
println("Title: ${openGraphDataDoc.title}")