fix: workaround for dollar sign in markdown (#996)

This commit is contained in:
Diego Beraldin 2024-06-17 13:28:21 +02:00 committed by GitHub
parent 4f23ecd5c6
commit 7208be7b3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,11 +18,13 @@ internal fun ASTNode.findChildOfTypeRecursive(type: IElementType): ASTNode? {
}
internal fun String.sanitize(): String =
this.removeEntities()
this
.removeEntities()
.spoilerFixUp()
.quoteFixUp()
.expandLemmyHandles()
.cleanupEscapes()
.dollarSignFixUp()
.emptyLinkFixup()
private fun String.removeEntities(): String =
@ -80,9 +82,12 @@ private fun String.quoteFixUp(): String =
finalLines.joinToString("\n")
}
private fun String.expandLemmyHandles(): String =
LemmyLinkRegex.lemmyHandle.replace(this, "[$1@$2](!$1@$2)")
private fun String.expandLemmyHandles(): String = LemmyLinkRegex.lemmyHandle.replace(this, "[$1@$2](!$1@$2)")
private fun String.cleanupEscapes(): String = replace("\\#", "#")
private fun String.dollarSignFixUp(): String =
// due to a bug in how the renderer builds annotated strings, replace with full width dollar sign
replace("$", "\uff04")
private fun String.emptyLinkFixup(): String = replace("[]()", "")