-
Notifications
You must be signed in to change notification settings - Fork 169
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 super and sub script not being properly rendered #1410
Conversation
This doesn't work in Lemmy UI So I assume ~ and ^ are markdown specs set by lemmy? Too bad there never was a formal syntax spec for markdown. Is this something that could be considered added to Lemmy UI or does Jerboa need to support ~ and ^ too? That will be more complex as Markwon is kinda of enigma |
Yep, lemmy uses a few things that aren't in the commonmark spec (spoilers, sub/sup). Mostly we follow the standards for extensions used by the markdown-it extensions: https://github.com/markdown-it/markdown-it?tab=readme-ov-file#syntax-extensions |
@@ -584,7 +584,8 @@ fun MarkdownHelperBar( | |||
IconButton( | |||
onClick = { | |||
simpleMarkdownSurround( | |||
"~", | |||
startText = "<sub>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the right way to do it, we have to follow the conventions here (but it looks like I need to fix super and subscript there also) , so that all lemmy clients can support it.
This needs to be fixed in the markdown renderer.
The best way to test it to use lemmy-ui, and make sure the rendered, and view source, match both on jerboa and lemmy-ui.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly sure also that these already exist in eternity, and could be taken from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked eternity only supports superscript and its slightly different syntax too. its just ^
Their execution is very complex.
Imo I think we can achieve something better with a plugin that just rewrites ^^ and ~~ to their html tags equivalent. But from user perspective it will look like its ^^
. That way we wont need to maintain all this super complex logic that seems to depend on other custom markwon nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree. There's a simple example of altering the markdown string before processing here: https://noties.io/Markwon/docs/v4/core/plugins.html#process-markdown
It'd be much easier to do regex to replace ^...^
with <sup>...</sup>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, this is so much better.
Fix #1341