From 32f93a670eec3f6c13797eebc59247be7b1c8684 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:20:58 +0000 Subject: [PATCH] Fix link text extraction in MarkdownToInlinesConverter to handle formatted inline children - Add GetPlainText helper that recursively collects text from all inline children (LiteralInline for leaf text, ContainerInline recurses into children) - Use GetPlainText(link) instead of .OfType() so bold/italic labels like [**text**](url) are rendered correctly - Fix BulletType: ListBlock.BulletType is a char in Markdig, not an enum; remove the incorrect switch expression and use the char directly Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Converters/MarkdownToInlinesConverter.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs b/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs index 6d458d75..2e6de2a2 100644 --- a/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs +++ b/DiscordChatExporter.Gui/Converters/MarkdownToInlinesConverter.cs @@ -20,6 +20,14 @@ public class MarkdownToInlinesConverter : IValueConverter .UseEmphasisExtras() .Build(); + private static string GetPlainText(MarkdownInline inline) => + inline switch + { + LiteralInline literal => literal.Content.ToString(), + ContainerInline container => string.Concat(container.Select(GetPlainText)), + _ => string.Empty, + }; + private static void ProcessInline( InlineCollection inlines, MarkdownInline markdownInline, @@ -83,13 +91,7 @@ public class MarkdownToInlinesConverter : IValueConverter { inlines.Add( new InlineUIContainer( - new HyperLink - { - Text = string.Concat( - link.OfType().Select(l => l.Content.ToString()) - ), - Url = link.Url, - } + new HyperLink { Text = GetPlainText(link), Url = link.Url } ) ); @@ -147,15 +149,7 @@ public class MarkdownToInlinesConverter : IValueConverter inlines.Add(new LineBreak()); isFirst = false; - var bulletChar = list.BulletType switch - { - BulletType.Dash => '-', - BulletType.Plus => '+', - BulletType.Asterisk => '*', - _ => '-' - }; - - var prefix = list.IsOrdered ? $"{itemOrder++}. " : $"{bulletChar} "; + var prefix = list.IsOrdered ? $"{itemOrder++}. " : $"{list.BulletType} "; inlines.Add(new Run(prefix)); foreach (var subBlock in listItem.OfType())