Fixes for edge cases with markdown link parsing #898
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
This PR fixes the issues mentioned in #896 and changes the underlying logic that enables long-press actions for markdown links. The fix for this ended up being more complicated than initially thought due to some of the behaviours of custom markdown elements.
Duplicate markdown text
I was not able to fully narrow down the cause of this issue. However, my assumption revolves around how
MarkdownElementBuilder
handles links and text. This could be due to the case where[some text](somelink)
gets split up into multiple elements, and causes some weird behaviours when attempting to render the widget.Smaller font sizes for links
While
MarkdownElementBuilder
does pass down the text styles down,RichText
requiresTextStyle
s to be explicitly set. Furthermore, surrounding the text with anInkWell
causes the text to shrink slightly.Markdown links are sometimes missing
This is also a weird issue that I could not fully track down. It seems like its a combination of how RichText, TextSpan, InkWell, and WidgetSpan interact with one another. It seems like some combinations
Resolution
To resolve these issues, and some other issues (WidgetSpans not allowing long links to be soft-wrapped, causing them to show up on a new line), I've created some new classes which extend the behaviour of
MarkdownBody
andMarkdownWidget
.I've extended their behaviours to add a
onLongPressLink
callback function which acts similar toonTapLink
. The one caveat so far is that theInkWell
is no longer present on links, but that can be addressed in the future as that feature is less critical than the link parsing.Additionally, I've fixed #897 and I've added an InlineExtension to properly highlight Lemmy links:
LemmyLinkSyntax
. This portion of the code is originally from Liftoff, so I'll give credits to that!@micahmo - I'm just cc-ing you in this PR so that you're aware of the changes to the logic! No need to do any reviews or testing 😁
Issue Being Fixed
Issue Number: #896, #897
Screenshots / Recordings
Checklist
semanticLabel
s where applicable for accessibility?