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 super and sub script not being properly rendered #1410

Merged
merged 4 commits into from
Mar 1, 2024

Conversation

MV-GH
Copy link
Collaborator

@MV-GH MV-GH commented Feb 25, 2024

image

Fix #1341

@MV-GH MV-GH requested a review from dessalines as a code owner February 25, 2024 22:59
@MV-GH
Copy link
Collaborator Author

MV-GH commented Feb 25, 2024

image

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

@dessalines
Copy link
Member

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>",
Copy link
Member

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.

Copy link
Member

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.

Copy link
Collaborator Author

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 ^

image

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.

Copy link
Member

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>.

@MV-GH MV-GH marked this pull request as draft February 27, 2024 23:10
@MV-GH
Copy link
Collaborator Author

MV-GH commented Feb 29, 2024

image

Works pretty great, and much simpler

@MV-GH MV-GH marked this pull request as ready for review February 29, 2024 20:58
@MV-GH MV-GH changed the title Fix super and sub script not working Fix super and sub script not being properly rendered Feb 29, 2024
Copy link
Member

@dessalines dessalines left a 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.

@dessalines dessalines merged commit ac39d87 into LemmyNet:main Mar 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sub and super script in markdown doesn't work
2 participants