Skip to content

Commit

Permalink
Merge pull request #21 from fleeksoft/develop
Browse files Browse the repository at this point in the history
Release 0.1.1
  • Loading branch information
itboy87 authored Dec 19, 2023
2 parents 911a3cf + ecae743 commit 698b997
Show file tree
Hide file tree
Showing 71 changed files with 6,682 additions and 1,999 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
**Sample Code**
If applicable, add sample code or snippets to help explain your problem.

**Device (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Device: [e.g. Android]
- OS: [e.g. Android]
- Version [e.g. 22]


Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ captures
local.properties
xcuserdata
/gpg/
/kotlin-js-store/
6 changes: 2 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ agp = "8.1.3"
kotlin = "1.9.21"
compileSdk = "34"
minSdk = "21"
libraryVersion = "0.1.0"
libraryVersion = "0.1.1"
junitJupiter = "5.10.0"
compose = "1.5.4"
compose-compiler = "1.5.4"
compose-material3 = "1.1.2"
androidx-activityCompose = "1.8.1"
ktor = "2.3.6"
ktor = "2.3.7"
coroutines = "1.7.3"
okio = "3.6.0"
kotlinxDatetime = "0.5.0"
kotlinx-io = "0.3.0"
codepoints = "0.6.1"
gson = "2.10.1"
dokka = "1.9.10"
vanniktect-publish = "0.25.3"

Expand All @@ -41,7 +40,6 @@ okio-nodefilesystem = { module = "com.squareup.okio:okio-nodefilesystem", versio
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" }
codepoints = { module = "de.cketti.unicode:kotlin-codepoints-deluxe", version.ref = "codepoints" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down
1 change: 0 additions & 1 deletion ksoup/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ kotlin {
this.kotlin.srcDir(layout.buildDirectory.file(rootPath))
dependencies {
implementation(libs.kotlin.test)
implementation(libs.gson)
implementation(projects.ksoupNetwork)
}
}
Expand Down
16 changes: 7 additions & 9 deletions ksoup/src/commonMain/kotlin/com/fleeksoft/ksoup/Ksoup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public object Ksoup {
* @return sane HTML
* @throws IOException if the file could not be found or read.
* @see .parse
* @since 1.15.1
*/
@Throws(IOException::class)
public fun parseFile(file: String): Document {
Expand All @@ -147,7 +146,6 @@ public object Ksoup {
* @param parser alternate [parser][Parser.xmlParser] to use.
* @return sane HTML
* @throws IOException if the file could not be found, or read, or if the charsetName is invalid.
* @since 1.14.2
*/
@Throws(IOException::class)
public fun parseFile(
Expand Down Expand Up @@ -264,11 +262,11 @@ public object Ksoup {
* cleaning the document.
*
* Example:
* <pre>`String sourceBodyHtml = "<p>5 is &lt; 6.</p>";
* String html = Jsoup.clean(sourceBodyHtml, Safelist.none());
* <pre>`val sourceBodyHtml = "<p>5 is &lt; 6.</p>";
* val html = Ksoup.clean(sourceBodyHtml, Safelist.none())
*
* Cleaner cleaner = new Cleaner(Safelist.none());
* String text = cleaner.clean(Ksoup.parse(sourceBodyHtml)).text();
* val cleaner = Cleaner(Safelist.none());
* val text = cleaner.clean(Ksoup.parse(sourceBodyHtml)).text()
*
* // html is: 5 is &lt; 6.
* // text is: 5 is < 6.
Expand Down Expand Up @@ -326,9 +324,9 @@ public object Ksoup {
*
*
* Example:
* <pre>`Safelist safelist = Safelist.relaxed();
* boolean isValid = Jsoup.isValid(sourceBodyHtml, safelist);
* String normalizedHtml = Jsoup.clean(sourceBodyHtml, "https://example.com/", safelist);
* <pre>`val safelist = Safelist.relaxed()
* val isValid = Ksoup.isValid(sourceBodyHtml, safelist)
* val normalizedHtml = Ksoup.clean(sourceBodyHtml, "https://example.com/", safelist)
`</pre> *
*
* Assumes the HTML is a body fragment (i.e. will be used in an existing HTML document body.)
Expand Down
29 changes: 0 additions & 29 deletions ksoup/src/commonMain/kotlin/com/fleeksoft/ksoup/helper/DataUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import com.fleeksoft.ksoup.nodes.Node
import com.fleeksoft.ksoup.nodes.XmlDeclaration
import com.fleeksoft.ksoup.parser.Parser
import com.fleeksoft.ksoup.ported.*
import com.fleeksoft.ksoup.ported.canEncode
import com.fleeksoft.ksoup.ported.isCharsetSupported
import com.fleeksoft.ksoup.readFile
import com.fleeksoft.ksoup.readGzipFile
import com.fleeksoft.ksoup.select.Elements
import io.ktor.utils.io.charsets.*
import okio.*
import okio.Buffer
import kotlin.random.Random

/**
Expand All @@ -29,7 +26,6 @@ public object DataUtil {
Regex("charset=\\s*['\"]?([^\\s,;'\"]*)", RegexOption.IGNORE_CASE)
private val defaultCharsetName: String = Charsets.UTF_8.name // used if not found in header or meta charset
private const val firstReadBufferSize: Long = (1024 * 5).toLong()
private const val bufferSize: Long = (1024 * 32).toLong()
private val mimeBoundaryChars =
"-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()
public const val boundaryLength: Int = 32
Expand Down Expand Up @@ -66,7 +62,6 @@ public object DataUtil {
*
* @return Document
* @throws IOException on IO error
* @since 1.14.2
*/
@Throws(IOException::class)
public fun load(
Expand Down Expand Up @@ -294,9 +289,6 @@ public object DataUtil {
bufferReader: BufferReader,
maxSize: Long,
): ByteArray {
require(maxSize >= 0) {
"maxSize must be 0 (unlimited) or larger"
}
return if (maxSize == 0L) {
bufferReader.readByteArray()
} else {
Expand All @@ -311,7 +303,6 @@ public object DataUtil {
* @param contentType e.g. "text/html; charset=EUC-JP"
* @return "EUC-JP", or null if not found. Charset is trimmed and uppercased.
*/
// @Nullable
internal fun getCharsetFromContentType(contentType: String?): String? {
if (contentType == null) return null
val matchResult: MatchResult? = charsetPattern.find(contentType)
Expand Down Expand Up @@ -350,26 +341,6 @@ public object DataUtil {
return StringUtil.releaseBuilder(mime)
}

// @Nullable
/*private fun detectCharsetFromBom(reader: Reader): BomCharset? {
val snapshot = okio.Buffer()
reader.copyTo(snapshot, 0, min(4, reader.size))
val bom = snapshot.readByteArray()
if (bom[0].toInt() == 0x00 && bom[1].toInt() == 0x00 && bom[2] == 0xFE.toByte() && bom[3] == 0xFF.toByte() || // BE
bom[0] == 0xFF.toByte() && bom[1] == 0xFE.toByte() && bom[2].toInt() == 0x00 && bom[3].toInt() == 0x00
) { // LE
return BomCharset("UTF-32", false) // and I hope it's on your system
} else if (bom[0] == 0xFE.toByte() && bom[1] == 0xFF.toByte() || // BE
bom[0] == 0xFF.toByte() && bom[1] == 0xFE.toByte()
) {
return BomCharset("UTF-16", false) // in all Javas
} else if (bom[0] == 0xEF.toByte() && bom[1] == 0xBB.toByte() && bom[2] == 0xBF.toByte()) {
return BomCharset("UTF-8", true) // in all Javas
// 16 and 32 decoders consume the BOM to determine be/le; utf-8 should be consumed here
}
return null
}*/

private fun detectCharsetFromBom(firstByteArray: ByteArray): BomCharset? {
// .mark and rewind used to return Buffer, now ByteBuffer, so cast for backward compat
val bom =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,4 @@ package com.fleeksoft.ksoup.helper
/**
* Validation exceptions, as thrown by the methods in [Validate].
*/
public class ValidationException(msg: String?) : IllegalArgumentException(msg) {
// TODO: incomplete
/*@Synchronized
overrie fun fillInStackTrace(): Throwable {
// Filters out the Validate class from the stacktrace, to more clearly point at the root-cause.
super.fillInStackTrace()
val stackTrace: Array<StackTraceElement> = getStackTrace()
val filteredTrace: MutableList<java.lang.StackTraceElement> =
ArrayList<java.lang.StackTraceElement>()
for (trace in stackTrace) {
if (trace.getClassName() == Validator) continue
filteredTrace.add(trace)
}
setStackTrace(filteredTrace.toTypedArray<java.lang.StackTraceElement>())
return this
}*/

/*companion object {
val Validator: String = Validate::class.java.getName()
}*/
}
public class ValidationException(msg: String?) : IllegalArgumentException(msg)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.fleeksoft.ksoup.internal

/**
* ksoup constants used between packages. Do not use as they may change without warning. Users will not be able to see
* this package when modules are enabled.
*/
public object SharedConstants {
public const val UserDataKey: String = "/ksoup.userdata"
public const val AttrRangeKey: String = "ksoup.attrs"
public const val RangeKey: String = "ksoup.start"
public const val EndRangeKey: String = "ksoup.end"

public const val DefaultBufferSize: Int = 1024 * 32
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ internal object StringUtil {
return false
}

fun inSorted(needle: String, haystack: Array<String>): Boolean {
fun inSorted(needle: String, haystack: Array<out String>): Boolean {
return haystack.toList().binarySearch(needle) >= 0
}

Expand Down Expand Up @@ -327,7 +327,6 @@ internal object StringUtil {

/**
* A StringJoiner allows incremental / filtered joining of a set of stringable objects.
* @since 1.14.1
*/
class StringJoiner
/**
Expand Down
Loading

0 comments on commit 698b997

Please sign in to comment.