Fixed attention guide crash on non-alphanumeric words

This commit is contained in:
Corewala 2022-05-30 11:38:45 -04:00
parent d247b17999
commit 60673c2fb3
1 changed files with 12 additions and 7 deletions

View File

@ -303,14 +303,19 @@ class GemtextAdapter(
.append("${component.substring(index)}$joiner")
} else {
var offset = 1
while (!component.substring(offset).first().isLetterOrDigit()) {
offset += 1
if (component.length - offset > 1) {
while (!component.substring(offset).first().isLetterOrDigit()) {
offset += 1
}
val index = (component.length - offset) / 2
attentionGuideText
.append(component.substring(0, offset))
.bold { append(component.substring(offset, index + offset)) }
.append("${component.substring(index + offset)}$joiner")
}else{
attentionGuideText.append("$component$joiner")
}
val index = (component.length - offset) / 2
attentionGuideText
.append(component.substring(0, offset))
.bold { append(component.substring(offset, index + offset)) }
.append("${component.substring(index + offset)}$joiner")
}
} else {
attentionGuideText.append("$component$joiner")