MarkdownTextBlock throws an ArgumentException when using a markdown link with a superscript link as text #3986
Replies: 4 comments
-
Thanks @Sergio0694, Is the |
Beta Was this translation helpful? Give feedback.
-
Hi @michael-hawker - it's not supported on GitHub, but it's part of Reddit's markdown (docs here). I do agree that having a superscript link inside a markdown link is a bit too much (found this while randomly looking at some markdown examples), but I think it'd be great if this was either added, or if the control could just fallback and render the current line as plaintext, if something in it caused a crash. EDIT: Just gave it a try and found a very quick workaround that works fine though: // Add it to the current inlines
try
{
localContext.InlineCollection.Add(link);
LinkRegister.RegisterNewHyperLink(link, element.Url);
}
catch
{
// Invalid nested hyperlink, just add as a run
link.Inlines.Clear();
localContext.InlineCollection.Add(linkText);
} This would be over this line (moving that link registering from the previous line as well): https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/a722f171cac7959d8fb39d732c5951018a2e8c07/Microsoft.Toolkit.Uwp.UI.Controls/MarkdownTextBlock/Render/MarkdownRenderer.Inlines.cs#L217 This way if the |
Beta Was this translation helpful? Give feedback.
-
@Sergio0694 thanks for the link! Yeah, in many cases we should try and fail more gracefully and just render plaintext. @WilliamABradley any thoughts on a more general way to do this? |
Beta Was this translation helpful? Give feedback.
-
This issue seems inactive. It will automatically be closed in 14 days if there is no activity. |
Beta Was this translation helpful? Give feedback.
-
I'm submitting a...
Current behavior
Trying to render a markdown like this throws an
ArgumentException
:The crash happens at the last line,
localContext.InlineCollection.Add(link);
, from this method: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/a722f171cac7959d8fb39d732c5951018a2e8c07/Microsoft.Toolkit.Uwp.UI.Controls/MarkdownTextBlock/Render/MarkdownRenderer.Inlines.cs#L188This is probably related in some way to #2802
Expected behavior
The markdown should be correctly rendered as a superscript link.
Minimal reproduction of the problem with instructions
Write the following text in a
MarkdownTextBlock
control:Environment
Beta Was this translation helpful? Give feedback.
All reactions