mirror of
https://github.com/Corewala/Buran
synced 2025-01-03 05:34:28 +00:00
Attention guides can handle hyphens
This commit is contained in:
parent
8cde96c971
commit
5bb5fa7dcb
1 changed files with 26 additions and 17 deletions
|
@ -287,25 +287,34 @@ class GemtextAdapter(
|
|||
|
||||
val attentionGuideText = SpannableStringBuilder()
|
||||
for(word in wordList){
|
||||
if(word.length > 1){
|
||||
if(word.first().isLetterOrDigit()){
|
||||
val index = word.length/2
|
||||
attentionGuideText
|
||||
.bold{append(word.substring(0, index))}
|
||||
.append("${word.substring(index)} ")
|
||||
val wordComponents = word.split("-")
|
||||
|
||||
for(component in wordComponents) {
|
||||
val joiner = if((wordComponents.size > 1) and (wordComponents.indexOf(component) != wordComponents.size - 1)){
|
||||
"-"
|
||||
}else{
|
||||
" "
|
||||
}
|
||||
if (component.length > 1) {
|
||||
if (component.first().isLetterOrDigit()) {
|
||||
val index = component.length / 2
|
||||
attentionGuideText
|
||||
.bold { append(component.substring(0, index)) }
|
||||
.append("${component.substring(index)}$joiner")
|
||||
} else {
|
||||
var offset = 1
|
||||
while(!word.substring(offset).first().isLetterOrDigit()){
|
||||
while (!component.substring(offset).first().isLetterOrDigit()) {
|
||||
offset += 1
|
||||
}
|
||||
val index = (word.length - offset)/2
|
||||
val index = (component.length - offset) / 2
|
||||
attentionGuideText
|
||||
.append(word.substring(0, offset))
|
||||
.bold{append(word.substring(offset, index + offset))}
|
||||
.append("${word.substring(index + offset)} ")
|
||||
.append(component.substring(0, offset))
|
||||
.bold { append(component.substring(offset, index + offset)) }
|
||||
.append("${component.substring(index + offset)}$joiner")
|
||||
}
|
||||
} else {
|
||||
attentionGuideText.append("$component$joiner")
|
||||
}
|
||||
}else{
|
||||
attentionGuideText.append("$word ")
|
||||
}
|
||||
}
|
||||
return attentionGuideText
|
||||
|
|
Loading…
Reference in a new issue