From 46450367e370d271a111d1ccc4baf6899f4263ed Mon Sep 17 00:00:00 2001 From: Emily <89871431+emillly-b@users.noreply.github.com> Date: Sat, 16 Oct 2021 08:29:59 -0500 Subject: [PATCH] Add markdown support for channel topics in HTML export (#720) Co-authored-by: Alexey Golub <1935960+Tyrrrz@users.noreply.github.com> --- .../Exporting/Writers/Html/PreambleTemplate.cshtml | 4 +++- .../Exporting/Writers/Html/PreambleTemplateContext.cs | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml index e8c89db..44874d7 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplate.cshtml @@ -14,6 +14,8 @@ string FormatDate(DateTimeOffset date) => Model.ExportContext.FormatDate(date); ValueTask ResolveUrlAsync(string url) => Model.ExportContext.ResolveMediaUrlAsync(url, CancellationToken); + + string FormatMarkdown(string markdown) => Model.FormatMarkdown(markdown); } @@ -692,7 +694,7 @@ @if (!string.IsNullOrWhiteSpace(Model.ExportContext.Request.Channel.Topic)) { -
@Model.ExportContext.Request.Channel.Topic
+
@Raw(FormatMarkdown(Model.ExportContext.Request.Channel.Topic))
} @if (Model.ExportContext.Request.After is not null || Model.ExportContext.Request.Before is not null) diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplateContext.cs b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplateContext.cs index 6dc335b..18b0d51 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplateContext.cs +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/PreambleTemplateContext.cs @@ -1,4 +1,6 @@ -namespace DiscordChatExporter.Core.Exporting.Writers.Html +using DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors; + +namespace DiscordChatExporter.Core.Exporting.Writers.Html { internal class PreambleTemplateContext { @@ -11,5 +13,8 @@ ExportContext = exportContext; ThemeName = themeName; } + + public string FormatMarkdown(string? markdown, bool isJumboAllowed = true) => + HtmlMarkdownVisitor.Format(ExportContext, markdown ?? "", isJumboAllowed); } } \ No newline at end of file