fix: spoiler detection regex and cleaning (#787)

This commit is contained in:
Diego Beraldin 2024-05-05 09:41:11 +02:00 committed by GitHub
parent d58d2ba4b4
commit a6675a5563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package com.github.diegoberaldin.raccoonforlemmy.core.markdown
internal object SpoilerRegex {
val spoilerOpening = Regex("(:::\\s+spoiler\\s+)(?<title>.*)")
val spoilerOpening = Regex("(:::\\s?spoiler\\s+)(?<title>.*)")
val spoilerClosing = Regex(":::")
}

View File

@ -44,9 +44,9 @@ private fun String.spoilerFixUp(): String = run {
finalLinesSizeAtLastSpoiler = finalLines.size
} else if (line.isNotBlank()) {
if (isSpoilerOnTopOfStack) {
// removes list inside spoilers
// removes list and blank lines inside spoilers
val cleanLine = line.replace(Regex("^\\s*?- "), "").trim()
if (cleanLine.isNotEmpty()) {
if (cleanLine.isNotBlank()) {
finalLines += cleanLine
}
} else {