Skip to content

fix: strikethrough doesn't render with underline #300

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Saif-Alhaider
Copy link
Contributor

Fix: Strikethrough Links Not Rendering Properly

This PR fixes the issue where strikethrough links (e.g., ~[This is a link](https://example.com)~) were not displaying the strikethrough effect. Now, both the link styling and strikethrough are correctly applied.

Closes #299

@mikepenz
Copy link
Owner

mikepenz commented Feb 6, 2025

Thank you very much for the PR, I'll have to look more into it. What worries me a bit is that we specifically have to look out for strikethrough in that case, and are not depending on the general annotated string builder which would handle more than just strikethrough.

test italic bold strikethrough italic test

@Saif-Alhaider
Copy link
Contributor Author

Thank you for the feedback, I understand the concern about handling only strikethrough and not relying on the general AnnotatedString Builder. I'll look into finding a solution to ensure we handle multiple text styles (like italic, bold, and strikethrough) in a more integrated way. I'll keep you updated on my progress.

@mikepenz
Copy link
Owner

mikepenz commented Feb 6, 2025

Strictly speaking all the spans should already be applied at that point 🤔 I suppose the way compose handles links inside an annotated string overrides all the other spans that apply to this section already.

I also just realized that my example was the inverse :D where the style was within the link and not from the outside.

Generally we might need to do something like this:
https://github.com/mikepenz/multiplatform-markdown-renderer/blob/develop/multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/compose/extendedspans/SquigglyUnderlineSpanPainter.kt#L115-L119

where we get the spans for the range of the string and apply the similar "special" text stylings like underline, bold, italic, strikethrough, ...

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2025

Testing with:

[test *italic* **bold** ~strikethrough~ _italic_ test](https://mikepenz.dev)
*[italic](https://mikepenz.dev)*
**[bold](https://mikepenz.dev)**
~[strikethrough](https://mikepenz.dev)~
_[italic](https://mikepenz.dev)_
Screenshot 2025-02-07 at 11 25 44

It seems like only strikethrough is not respected

withLink(LinkAnnotation.Url(annotation, annotatorSettings.linkTextSpanStyle, annotatorSettings.linkInteractionListener)) {
text?.let { annotatorSettings.referenceLinkHandler?.store(it, annotation) }

val linkStyle = if (node.parent?.type == GFMElementTypes.STRIKETHROUGH) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-02-07 at 11 42 57

Looking more into this. parent wouldn't work unfortunately. as the link style may be surrounding nodes.

I wonder if the problem should be mostly considered to be they way TextLinkStyles work in annotated strings :/

@mikepenz
Copy link
Owner

mikepenz commented Feb 7, 2025

as we are in that stage still using a AnnotatedString.Builder we also can't get the applied spans yet. so that ain't work either

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.

Bug: Strikethrough Links Not Rendering Correctly
2 participants