mirror of https://github.com/Corewala/Buran
Attention guides can handle hyphens
This commit is contained in:
parent
8cde96c971
commit
5bb5fa7dcb
|
@ -287,25 +287,34 @@ class GemtextAdapter(
|
||||||
|
|
||||||
val attentionGuideText = SpannableStringBuilder()
|
val attentionGuideText = SpannableStringBuilder()
|
||||||
for(word in wordList){
|
for(word in wordList){
|
||||||
if(word.length > 1){
|
val wordComponents = word.split("-")
|
||||||
if(word.first().isLetterOrDigit()){
|
|
||||||
val index = word.length/2
|
for(component in wordComponents) {
|
||||||
attentionGuideText
|
val joiner = if((wordComponents.size > 1) and (wordComponents.indexOf(component) != wordComponents.size - 1)){
|
||||||
.bold{append(word.substring(0, index))}
|
"-"
|
||||||
.append("${word.substring(index)} ")
|
|
||||||
}else{
|
}else{
|
||||||
var offset = 1
|
" "
|
||||||
while(!word.substring(offset).first().isLetterOrDigit()){
|
}
|
||||||
offset += 1
|
if (component.length > 1) {
|
||||||
}
|
if (component.first().isLetterOrDigit()) {
|
||||||
val index = (word.length - offset)/2
|
val index = component.length / 2
|
||||||
attentionGuideText
|
attentionGuideText
|
||||||
.append(word.substring(0, offset))
|
.bold { append(component.substring(0, index)) }
|
||||||
.bold{append(word.substring(offset, index + offset))}
|
.append("${component.substring(index)}$joiner")
|
||||||
.append("${word.substring(index + offset)} ")
|
} else {
|
||||||
|
var 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")
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
attentionGuideText.append("$word ")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return attentionGuideText
|
return attentionGuideText
|
||||||
|
|
Loading…
Reference in New Issue