extend regex, up version, fix enter on android tv

This commit is contained in:
2026-08-09 12:33:01 +03:00
parent 01c197379a
commit 009e25b846
3 changed files with 8 additions and 7 deletions
@@ -6,7 +6,7 @@ import ru.shadowsparky.chat.domain.TextToken
@Factory
class MovieTextParser : ChatTextParser {
private val regex = Regex("«(.*?)»|\"(.*?)\"")
private val regex = Regex("«(.*?)»|\"(.*?)\"|\\*\\*(.*?)\\*\\*")
override fun parse(content: String): List<TextToken> {
val tokens = mutableListOf<TextToken>()
@@ -16,11 +16,11 @@ class MovieTextParser : ChatTextParser {
tokens.add(TextToken.Plain(content.substring(lastIndex, matchResult.range.first)))
}
val movieTitle = matchResult.groupValues[1].takeIf { it.isNotEmpty() }
?: matchResult.groupValues[2]
tokens.add(TextToken.Link(text = movieTitle))
?: matchResult.groupValues[2].takeIf { it.isNotEmpty() }
?: matchResult.groupValues[3]
tokens.add(TextToken.Link(movieTitle))
lastIndex = matchResult.range.last + 1
}
if (lastIndex < content.length) {
tokens.add(TextToken.Plain(content.substring(lastIndex)))
}