@@ -2,6 +2,7 @@ package com.readrops.app.util
22
33import android.content.Context
44import androidx.annotation.VisibleForTesting
5+ import androidx.compose.ui.util.fastJoinToString
56import com.readrops.db.entities.Item
67import io.pebbletemplates.pebble.PebbleEngine
78import 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