up regex
This commit is contained in:
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = namespace
|
||||
minSdk = libs.versions.proj.min.get().toInt()
|
||||
targetSdk = libs.versions.proj.target.get().toInt()
|
||||
versionCode = 46
|
||||
versionName = "1.24.2"
|
||||
versionCode = 47
|
||||
versionName = "1.24.3"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -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>()
|
||||
@@ -15,10 +15,12 @@ class MovieTextParser : ChatTextParser {
|
||||
if (matchResult.range.first > lastIndex) {
|
||||
tokens.add(TextToken.Plain(content.substring(lastIndex, matchResult.range.first)))
|
||||
}
|
||||
val movieTitle = matchResult.groupValues[1]
|
||||
val movieTitle = matchResult.groupValues[1].takeIf { it.isNotEmpty() }
|
||||
?: matchResult.groupValues[2]
|
||||
tokens.add(TextToken.Link(text = movieTitle))
|
||||
lastIndex = matchResult.range.last + 1
|
||||
}
|
||||
|
||||
if (lastIndex < content.length) {
|
||||
tokens.add(TextToken.Plain(content.substring(lastIndex)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user