Skip to content

Commit 6703b94

Browse files
Add managed punctuation marks to fr_typo
1 parent 32fe420 commit 6703b94

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/src/main/java/com/readrops/app/util/ShareIntentTextRenderer.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.readrops.app.util
22

33
import android.content.Context
44
import androidx.annotation.VisibleForTesting
5+
import androidx.compose.ui.util.fastJoinToString
56
import com.readrops.db.entities.Item
67
import io.pebbletemplates.pebble.PebbleEngine
78
import io.pebbletemplates.pebble.extension.AbstractExtension
@@ -69,15 +70,17 @@ class FrenchTypography : DocumentedFilter() {
6970

7071
override fun generateDocumentation(context: Context) = context.getString(
7172
R.string.fr_typo_documentation,
72-
TOKENS.toCharArray().joinToString { context.getString(R.string.localised_quotes, it) }
73+
(leftTokens + rightTokens).joinToString { context.getString(R.string.localised_quotes, it) }
7374
)
7475

7576
companion object {
76-
private const val TOKENS = "!?;:"
77-
private val regex = "\\s+([$TOKENS]+)".toRegex()
77+
private val leftTokens = listOf("«")
78+
private val rightTokens = listOf("»", "!", "?", ";", ":")
79+
private val leftRegex = "([${leftTokens.joinToString("")}]+)\\s+".toRegex()
80+
private val rightRegex = "\\s+([${rightTokens.joinToString("")}]+)".toRegex()
7881

7982
@VisibleForTesting
80-
fun filter(input: String) = input.replace(regex, " $1")
83+
fun filter(input: String) = input.replace(leftRegex, "$1 ").replace(rightRegex, " $1")
8184
}
8285
}
8386

0 commit comments

Comments
 (0)