Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Strikethrough rendering #1445

Merged
merged 1 commit into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down
Expand Up @@ -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~"),
)
}