mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 17:40:42 +01:00
fix: spoiler detection regex and cleaning (#787)
This commit is contained in:
parent
d58d2ba4b4
commit
a6675a5563
@ -1,7 +1,7 @@
|
|||||||
package com.github.diegoberaldin.raccoonforlemmy.core.markdown
|
package com.github.diegoberaldin.raccoonforlemmy.core.markdown
|
||||||
|
|
||||||
internal object SpoilerRegex {
|
internal object SpoilerRegex {
|
||||||
val spoilerOpening = Regex("(:::\\s+spoiler\\s+)(?<title>.*)")
|
val spoilerOpening = Regex("(:::\\s?spoiler\\s+)(?<title>.*)")
|
||||||
val spoilerClosing = Regex(":::")
|
val spoilerClosing = Regex(":::")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ private fun String.spoilerFixUp(): String = run {
|
|||||||
finalLinesSizeAtLastSpoiler = finalLines.size
|
finalLinesSizeAtLastSpoiler = finalLines.size
|
||||||
} else if (line.isNotBlank()) {
|
} else if (line.isNotBlank()) {
|
||||||
if (isSpoilerOnTopOfStack) {
|
if (isSpoilerOnTopOfStack) {
|
||||||
// removes list inside spoilers
|
// removes list and blank lines inside spoilers
|
||||||
val cleanLine = line.replace(Regex("^\\s*?- "), "").trim()
|
val cleanLine = line.replace(Regex("^\\s*?- "), "").trim()
|
||||||
if (cleanLine.isNotEmpty()) {
|
if (cleanLine.isNotBlank()) {
|
||||||
finalLines += cleanLine
|
finalLines += cleanLine
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user