diff --git a/README.md b/README.md index 2057c6b..8a16200 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Ksoup is a lightweight Kotlin Multiplatform library for parsing HTML, extracting [![MohamedRejeb](https://raw.githubusercontent.com/MohamedRejeb/MohamedRejeb/main/badges/mohamedrejeb.svg)](https://github.com/MohamedRejeb) [![Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) [![BuildPassing](https://shields.io/badge/build-passing-brightgreen)](https://github.com/MohamedRejeb/ksoup/actions) +[![Maven Central](https://img.shields.io/maven-central/v/com.mohamedrejeb.ksoup/ksoup-html)](https://search.maven.org/search?q=g:%22com.mohamedrejeb.ksoup%22%20AND%20a:%22ksoup-html%22) ![Slide 16_9 - 1 (1)](https://github.com/MohamedRejeb/ksoup/assets/41842296/fc352215-c8fd-4274-8fc0-ee1c587bb930) @@ -21,10 +22,12 @@ Ksoup is a lightweight Kotlin Multiplatform library for parsing HTML, extracting ## Installation +[![Maven Central](https://img.shields.io/maven-central/v/com.mohamedrejeb.ksoup/ksoup-html)](https://search.maven.org/search?q=g:%22com.mohamedrejeb.ksoup%22%20AND%20a:%22ksoup-html%22) + Add the dependency below to your **module**'s `build.gradle.kts` or `build.gradle` file: ```kotlin -val version = "0.1.1" +val version = "0.1.2" // For parsing HTML implementation("com.mohamedrejeb.ksoup:ksoup-html:$version") diff --git a/build.gradle.kts b/build.gradle.kts index b6c64b0..f602eba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ allprojects { } group = "com.mohamedrejeb.ksoup" - version = "0.1.1" + version = "0.1.2" apply(plugin = "maven-publish") apply(plugin = "signing") diff --git a/ksoup-entites/src/commonMain/kotlin/com/mohamedrejeb/ksoup/entities/LookupTranslator.kt b/ksoup-entites/src/commonMain/kotlin/com/mohamedrejeb/ksoup/entities/LookupTranslator.kt index f27dc40..b3226d7 100644 --- a/ksoup-entites/src/commonMain/kotlin/com/mohamedrejeb/ksoup/entities/LookupTranslator.kt +++ b/ksoup-entites/src/commonMain/kotlin/com/mohamedrejeb/ksoup/entities/LookupTranslator.kt @@ -37,16 +37,16 @@ internal class LookupTranslator(lookupMap: Map) : StringTranslat longest = currentLongest } - override fun translate(input: String, index: Int, stringBuilder: StringBuilder): Int { - // check if translation exists for the input at position index - if (prefixSet.contains(input[index].code.toUShort())) { + override fun translate(input: String, offset: Int, stringBuilder: StringBuilder): Int { + // check if translation exists for the input at position offset + if (prefixSet.contains(input[offset].code.toUShort())) { var max = longest - if (index + longest > input.length) { - max = input.length - index + if (offset + longest > input.length) { + max = input.length - offset } // implement greedy algorithm by trying maximum match first for (i in max downTo shortest) { - val subSeq = input.subSequence(index, index + i) + val subSeq = input.subSequence(offset, offset + i) val result = lookupMap[subSeq.toString()] if (result != null) { stringBuilder.append(result)