Skip to content

Commit

Permalink
Merge pull request #2 from MohamedRejeb/upgrade
Browse files Browse the repository at this point in the history
Update version to 0.1.2
  • Loading branch information
MohamedRejeb committed May 11, 2023
2 parents 7f17448 + a8fa309 commit f11cefe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ allprojects {
}

group = "com.mohamedrejeb.ksoup"
version = "0.1.1"
version = "0.1.2"

apply(plugin = "maven-publish")
apply(plugin = "signing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ internal class LookupTranslator(lookupMap: Map<String, String>) : 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)
Expand Down

0 comments on commit f11cefe

Please sign in to comment.