Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,37 @@ fun AnnotatedString.Builder.appendMarkdownLink(
return
}
val text = linkText.firstOrNull()?.getUnescapedTextInNode(content)
val destination = node.findChildOfType(MarkdownElementTypes.LINK_DESTINATION)?.getUnescapedTextInNode(content)
val linkLabel = node.findChildOfType(MarkdownElementTypes.LINK_LABEL)?.getUnescapedTextInNode(content)
val destination =
node.findChildOfType(MarkdownElementTypes.LINK_DESTINATION)?.getUnescapedTextInNode(content)
val linkLabel =
node.findChildOfType(MarkdownElementTypes.LINK_LABEL)?.getUnescapedTextInNode(content)
val annotation = destination ?: linkLabel

if (annotation != null) {
if (text != null) annotatorSettings.referenceLinkHandler?.store(text, annotation)
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 :/

annotatorSettings.linkTextSpanStyle.withUnderline()
} else {
annotatorSettings.linkTextSpanStyle
}

withLink(LinkAnnotation.Url(annotation, linkStyle, annotatorSettings.linkInteractionListener)) {
buildMarkdownAnnotatedString(content, linkText, annotatorSettings)
}
} else {
buildMarkdownAnnotatedString(content, linkText, annotatorSettings)
}

}

fun TextLinkStyles.withUnderline(): TextLinkStyles {
return TextLinkStyles(
style = style?.merge(SpanStyle(textDecoration = TextDecoration.LineThrough + TextDecoration.Underline)),
focusedStyle = focusedStyle,
hoveredStyle = hoveredStyle,
pressedStyle = pressedStyle
)
}

/**
Expand Down