diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html index 232b667..1126594 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html @@ -2,208 +2,214 @@ - {{ Guild.Name | HtmlEncode }} - {{ Channel.Name | HtmlEncode }} + {{ Guild.Name | html.escape }} - {{ Channel.Name | html.escape }} - + -{{~ # Info }} +{{~ # Info ~}}
-
{{ Guild.Name | HtmlEncode }}
-
{{ Channel.Name | HtmlEncode }}
+
{{ Guild.Name | html.escape }}
+
{{ Channel.Name | html.escape }}
- {{ if Channel.Topic }} -
{{ Channel.Topic | HtmlEncode }}
- {{ end }} + {{~ if Channel.Topic ~}} +
{{ Channel.Topic | html.escape }}
+ {{~ end ~}}
{{ TotalMessageCount | Format "N0" }} messages
- {{ if From || To }} + {{~ if From || To ~}}
- {{ if From && To }} - Between {{ From | FormatDate | HtmlEncode }} and {{ To | FormatDate | HtmlEncode }} - {{ else if From }} - After {{ From | FormatDate | HtmlEncode }} - {{ else if To }} - Before {{ To | FormatDate | HtmlEncode }} - {{ end }} + {{~ if From && To ~}} + Between {{ From | FormatDate | html.escape }} and {{ To | FormatDate | html.escape }} + {{~ else if From ~}} + After {{ From | FormatDate | html.escape }} + {{~ else if To ~}} + Before {{ To | FormatDate | html.escape }} + {{~ end ~}}
- {{ end }} + {{~ end ~}}
-{{~ # Log }} +{{~ # Log ~}}
- {{ for group in MessageGroups }} + {{~ for group in MessageGroups ~}}
- {{~ # Avatar }} + {{~ # Avatar ~}}
- {{~ # Author name and timestamp }} - {{ group.Author.Name | HtmlEncode }} - {{ group.Timestamp | FormatDate | HtmlEncode }} - - {{~ # Messages }} - {{ for message in group.Messages }} - {{~ # Content }} - {{ if message.Content }} + {{~ # Author name and timestamp ~}} + {{ group.Author.Name | html.escape }} + {{ group.Timestamp | FormatDate | html.escape }} + + {{~ # Messages ~}} + {{~ for message in group.Messages ~}} + {{~ # Content ~}} + {{~ if message.Content ~}}
{{ message.Content | FormatContent }} - {{~ # Edited timestamp }} - {{ if message.EditedTimestamp }} - (edited) - {{ end }} + {{~ # Edited timestamp ~}} + {{~ if message.EditedTimestamp ~}} + (edited) + {{~ end ~}}
- {{ end }} + {{~ end ~}} - {{~ # Attachments }} - {{ for attachment in message.Attachments }} + {{~ # Attachments ~}} + {{~ for attachment in message.Attachments ~}} - {{ end }} + {{~ end ~}} - {{~ # Embeds }} - {{ for embed in message.Embeds }} + {{~ # Embeds ~}} + {{~ for embed in message.Embeds ~}}
- {{~ # Author }} - {{ if embed.Author }} + {{~ # Author ~}} + {{~ if embed.Author ~}}
- {{ if embed.Author.IconUrl }} + {{~ if embed.Author.IconUrl ~}} - {{ end }} + {{~ end ~}} - {{ if embed.Author.Name }} + {{~ if embed.Author.Name ~}} - {{ if embed.Author.Url }} - {{ embed.Author.Name | HtmlEncode }} - {{ else }} - {{ embed.Author.Name | HtmlEncode }} - {{ end }} + {{~ if embed.Author.Url ~}} + {{ embed.Author.Name | html.escape }} + {{~ else ~}} + {{ embed.Author.Name | html.escape }} + {{~ end ~}} - {{ end }} + {{~ end ~}}
- {{ end }} + {{~ end ~}} - {{~ # Title }} - {{ if embed.Title }} + {{~ # Title ~}} + {{~ if embed.Title ~}}
- {{ if embed.Url }} + {{~ if embed.Url ~}} {{ embed.Title | FormatContent }} - {{ else }} + {{~ else ~}} {{ embed.Title | FormatContent }} - {{ end }} + {{~ end ~}}
- {{ end }} + {{~ end ~}} - {{~ # Description }} - {{ if embed.Description }} + {{~ # Description ~}} + {{~ if embed.Description ~}}
{{ embed.Description | FormatContent true }}
- {{ end }} - - {{~ # Fields }} -
- {{ for field in embed.Fields }} -
- {{ if field.Name }} -
{{ field.Name | FormatContent }}
- {{ end }} - {{ if field.Value }} -
{{ field.Value | FormatContent true }}
- {{ end }} -
- {{ end }} -
+ {{~ end ~}} + + {{~ # Fields ~}} + {{~ if embed.Fields | array.size > 0 ~}} +
+ {{~ for field in embed.Fields ~}} +
+ {{~ if field.Name ~}} +
{{ field.Name | FormatContent }}
+ {{~ end ~}} + {{~ if field.Value ~}} +
{{ field.Value | FormatContent true }}
+ {{~ end ~}} +
+ {{~ end ~}} +
+ {{~ end ~}}
- {{~ # Thumbnail }} - {{ if embed.Thumbnail }} + {{~ # Thumbnail ~}} + {{~ if embed.Thumbnail ~}} - {{ end }} + {{~ end ~}}
- {{~ # Image }} - {{ if embed.Image }} + {{~ # Image ~}} + {{~ if embed.Image ~}} - {{ end }} + {{~ end ~}} - {{~ # Footer }} - {{ if embed.Footer || embed.Timestamp }} + {{~ # Footer ~}} + {{~ if embed.Footer || embed.Timestamp ~}} - {{ end }} + {{~ end ~}}
- {{ end }} - - {{~ # Reactions }} -
- {{ for reaction in message.Reactions }} -
- - {{~ # Custom emoji }} - {{ if reaction.EmojiId }} - - {{~ # Default emoji }} - {{ else }} - {{ reaction.EmojiName }} - {{ end }} - - {{ reaction.Count }} -
- {{ end }} -
- {{ end }} + {{~ end ~}} + + {{~ # Reactions ~}} + {{~ if message.Reactions | array.size > 0 ~}} +
+ {{~ for reaction in message.Reactions ~}} +
+ + {{~ # Custom emoji ~}} + {{~ if reaction.EmojiId ~}} + + {{~ # Default emoji ~}} + {{~ else ~}} + {{ reaction.EmojiName }} + {{~ end ~}} + + {{ reaction.Count }} +
+ {{~ end ~}} +
+ {{~ end ~}} + {{~ end ~}}
- {{ end }} + {{~ end ~}}
diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/PlainText.txt b/DiscordChatExporter.Core/Resources/ExportTemplates/PlainText.txt index d5c729a..15a7330 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/PlainText.txt +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/PlainText.txt @@ -1,4 +1,5 @@ -============================================================== +{{~ # Info ~}} +============================================================== Guild: {{ Guild.Name }} Channel: {{ Channel.Name }} Topic: {{ Channel.Topic }} @@ -6,13 +7,19 @@ Messages: {{ TotalMessageCount | Format "N0" }} Range: {{ if From }}{{ From | FormatDate }} {{ end }}{{ if From || To }}->{{ end }}{{ if To }} {{ To | FormatDate }}{{ end }} ============================================================== +{{~ # Log ~}} {{~ for group in MessageGroups ~}} - {{~ group.Author.FullName }} [{{ group.Timestamp | FormatDate }}] + {{~ # Author name and timestamp ~}} + {{~ }}[{{ group.Timestamp | FormatDate }}] {{ group.Author.FullName }} + {{~ # Messages ~}} {{~ for message in group.Messages ~}} + {{~ # Content ~}} {{~ message.Content | FormatContent }} + {{~ # Attachments ~}} {{~ for attachment in message.Attachments ~}} {{~ attachment.Url }} {{~ end ~}} {{~ end ~}} + {{~ end ~}} \ No newline at end of file diff --git a/DiscordChatExporter.Core/Services/ExportService.TemplateModel.cs b/DiscordChatExporter.Core/Services/ExportService.TemplateModel.cs index c341267..522d914 100644 --- a/DiscordChatExporter.Core/Services/ExportService.TemplateModel.cs +++ b/DiscordChatExporter.Core/Services/ExportService.TemplateModel.cs @@ -28,8 +28,6 @@ namespace DiscordChatExporter.Core.Services private string HtmlEncode(string str) => WebUtility.HtmlEncode(str); - private string HtmlDecode(string str) => WebUtility.HtmlDecode(str); - private string Format(IFormattable obj, string format) => obj.ToString(format, CultureInfo.InvariantCulture); @@ -312,8 +310,6 @@ namespace DiscordChatExporter.Core.Services scriptObject.Import(_log, TemplateMemberFilter, TemplateMemberRenamer); // Import functions - scriptObject.Import(nameof(HtmlEncode), new Func(HtmlEncode)); - scriptObject.Import(nameof(HtmlDecode), new Func(HtmlDecode)); scriptObject.Import(nameof(Format), new Func(Format)); scriptObject.Import(nameof(FormatDate), new Func(FormatDate)); scriptObject.Import(nameof(FormatFileSize), new Func(FormatFileSize));