Repository: LemmyNet/jerboa (language: kotlin)

Issue:
Markdown strikethrough broken since new update
### Jerboa Version

0.0.62

### Android Version + Phone

Android 13 Samsung a53

### Describe The Bug

Hello :)

Since the last commit (ac39d872a805767d7910531c7619754744b670c8) strike through seems broken with the latest Jeboa app.

Editor screenshot:
![Screenshot_20240311_110011_Jerboa](https://github.com/dessalines/jerboa/assets/95717211/17e0dea7-ec32-4f1c-bb66-3debec9ac9f8)

Post screenshot:
![Screenshot_20240311_105952_Jerboa](https://github.com/dessalines/jerboa/assets/95717211/ce553234-5c12-4319-8267-a2ba90322dfb)

### To Reproduce

1. Create a post
2. Type some text
3. Use the  markdown syntax for strike through`~~text~~`
4. Observe the behavior

### In the case of a crash or when relevant include the logs

_No response_

---

Thanks for everything you do for the fediverse and native lemmy app !  keep it up :muscle: !


Discussion hints:
nan

Pull request: Fix Strikethrough rendering
Fixes #1444 

Test command: ./gradlew :app:testDebugUnitTest --tests "com.jerboa.util.markwon.ScriptRewriteSupportPluginTest"

Fix patch:
diff --git a/app/src/main/java/com/jerboa/util/markwon/ScriptRewriteSupportPlugin.kt b/app/src/main/java/com/jerboa/util/markwon/ScriptRewriteSupportPlugin.kt
index 9d61dc02d..e931cbcae 100644
--- a/app/src/main/java/com/jerboa/util/markwon/ScriptRewriteSupportPlugin.kt
+++ b/app/src/main/java/com/jerboa/util/markwon/ScriptRewriteSupportPlugin.kt
@@ -15,7 +15,7 @@ class ScriptRewriteSupportPlugin : AbstractMarkwonPlugin() {
 
     companion object {
         val SUPERSCRIPT_RGX = Regex("""\^([^\n^]+)\^""")
-        val SUBSCRIPT_RGX = Regex("""~([^\n~]+)~""")
+        val SUBSCRIPT_RGX = Regex("""(?<!~)~([^\n~]+)~""")
 
         fun rewriteLemmyScriptToMarkwonScript(text: String): String {
             return text


Test patch:
diff --git a/app/src/test/java/com/jerboa/util/markwon/ScriptRewriteSupportPluginTest.kt b/app/src/test/java/com/jerboa/util/markwon/ScriptRewriteSupportPluginTest.kt
index 1be365921..0164bacf4 100644
--- a/app/src/test/java/com/jerboa/util/markwon/ScriptRewriteSupportPluginTest.kt
+++ b/app/src/test/java/com/jerboa/util/markwon/ScriptRewriteSupportPluginTest.kt
@@ -28,10 +28,16 @@ class ScriptRewriteSupportPluginTest {
             listOf("^2^ ^2^", "<sup>2</sup> <sup>2</sup>"),
             listOf("^^", "^^"),
             listOf("^\n^", "^\n^"),
-            listOf("~2~~2~", "<sub>2</sub><sub>2</sub>"),
+            // Due to a parse limitation, the following case isn't fully supported
+            // The negative lookbehind matches with consumed tokens :/
+            listOf("~2~~2~", "<sub>2</sub>~2~"),
             listOf("~2~\n~2~", "<sub>2</sub>\n<sub>2</sub>"),
             listOf("~2~\n~2~", "<sub>2</sub>\n<sub>2</sub>"),
             listOf("~ blah blah", "~ blah blah"),
             listOf("", ""),
+            // Strikethrough syntax
+            listOf("~~text~~", "~~text~~"),
+            // Intended to fail, else it will increase the complexity of the regex by a huge margin
+            listOf("~~text~", "~~text~"),
         )
 }