File tree 5 files changed +22
-5
lines changed
app/src/main/java/com/nononsenseapps/feeder/ui/compose/text
5 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,20 @@ class AnnotatedParagraphStringBuilder {
35
35
return false
36
36
}
37
37
38
+ val endsWithNonBreakingSpace: Boolean
39
+ get() {
40
+ if (mLastTwoChars.isEmpty()) {
41
+ return false
42
+ }
43
+ mLastTwoChars.peekLatest()?.let { latest ->
44
+ if (latest.code == 160 ) {
45
+ return true
46
+ }
47
+ }
48
+
49
+ return false
50
+ }
51
+
38
52
fun pushVerbatimTtsAnnotation (verbatim : String ) =
39
53
builder.pushTtsAnnotation(VerbatimTtsAnnotation (verbatim))
40
54
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ class AnnotatedStringComposer : HtmlParser() {
9
9
strings
10
10
11
11
override fun emitParagraph (): Boolean {
12
- if (builder.isEmpty()) {
12
+ // List items emit dots and non-breaking space. Don't newline after that
13
+ if (builder.isEmpty() || builder.endsWithNonBreakingSpace) {
13
14
// Nothing to emit, and nothing to reset
14
15
return false
15
16
}
Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ class EagerComposer(
43
43
}
44
44
45
45
override fun emitParagraph (): Boolean {
46
- if (builder.isEmpty()) {
46
+ // List items emit dots and non-breaking space. Don't newline after that
47
+ if (builder.isEmpty() || builder.endsWithNonBreakingSpace) {
47
48
// Nothing to emit, and nothing to reset
48
49
return false
49
50
}
Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ private fun HtmlComposer.appendTextChildren(
578
578
.forEach { listItem ->
579
579
withParagraph {
580
580
// no break space
581
- append(" • " )
581
+ append(" •\u00A0 " )
582
582
appendTextChildren(
583
583
listItem.childNodes(),
584
584
baseUrl = baseUrl,
@@ -595,7 +595,7 @@ private fun HtmlComposer.appendTextChildren(
595
595
.forEachIndexed { i, listItem ->
596
596
withParagraph {
597
597
// no break space
598
- append(" ${i + 1 } . " )
598
+ append(" ${i + 1 } .\u00A0 " )
599
599
appendTextChildren(
600
600
listItem.childNodes(),
601
601
baseUrl = baseUrl,
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ class LazyListComposer(
11
11
) : HtmlComposer() {
12
12
13
13
override fun emitParagraph (): Boolean {
14
- if (builder.isEmpty()) {
14
+ // List items emit dots and non-breaking space. Don't newline after that
15
+ if (builder.isEmpty() || builder.endsWithNonBreakingSpace) {
15
16
// Nothing to emit, and nothing to reset
16
17
return false
17
18
}
You can’t perform that action at this time.
0 commit comments