diff --git a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs index f49c55a..31de461 100644 --- a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs +++ b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using DiscordChatExporter.Core.Markdown.Internal; @@ -57,6 +57,18 @@ namespace DiscordChatExporter.Core.Markdown new Regex("\\|\\|(.+?)\\|\\|", DefaultRegexOptions | RegexOptions.Singleline), (p, m) => new FormattedNode(TextFormatting.Spoiler, Parse(p.Shrink(m.Groups[1])))); + // Capture any character until the end of the line + // Opening 'greater than' character must be followed by whitespace + private static readonly IMatcher SingleLineQuoteNodeMatcher = new RegexMatcher( + new Regex("^>\\s(.+)\r?\n?", DefaultRegexOptions), + (p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Shrink(m.Groups[1])))); + + // Capture any character until the end of the input + // Opening 'greater than' characters must be followed by whitespace + private static readonly IMatcher MultiLineQuoteNodeMatcher = new RegexMatcher( + new Regex("^>>>\\s(.+)", DefaultRegexOptions | RegexOptions.Singleline), + (p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Shrink(m.Groups[1])))); + /* Code blocks */ // Capture any character except backtick until a backtick @@ -176,6 +188,8 @@ namespace DiscordChatExporter.Core.Markdown ItalicAltFormattedNodeMatcher, StrikethroughFormattedNodeMatcher, SpoilerFormattedNodeMatcher, + MultiLineQuoteNodeMatcher, + SingleLineQuoteNodeMatcher, // Code blocks MultiLineCodeBlockNodeMatcher, diff --git a/DiscordChatExporter.Core.Markdown/Nodes/TextFormatting.cs b/DiscordChatExporter.Core.Markdown/Nodes/TextFormatting.cs index 9a35c5a..b9c4813 100644 --- a/DiscordChatExporter.Core.Markdown/Nodes/TextFormatting.cs +++ b/DiscordChatExporter.Core.Markdown/Nodes/TextFormatting.cs @@ -6,6 +6,7 @@ Italic, Underline, Strikethrough, - Spoiler + Spoiler, + Quote } } \ No newline at end of file diff --git a/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs b/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs index 433c26d..fa994b9 100644 --- a/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs +++ b/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -81,6 +81,10 @@ namespace DiscordChatExporter.Core.Rendering // Spoiler if (formattedNode.Formatting == TextFormatting.Spoiler) return $"{innerHtml}"; + + // Quote + if (formattedNode.Formatting == TextFormatting.Quote) + return $"
{innerHtml}
"; } // Inline code block node diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css index f67b8fd..6233721 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css @@ -1,4 +1,4 @@ -/* === GENERAL === */ +/* === GENERAL === */ body { background-color: #36393e; @@ -13,6 +13,10 @@ a { background-color: rgba(255, 255, 255, 0.1); } +.quote { + border-color: #4f545c; +} + .pre { background-color: #2f3136 !important; } diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css index e139299..65f0f62 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css @@ -1,4 +1,4 @@ -/* === GENERAL === */ +/* === GENERAL === */ body { background-color: #ffffff; @@ -14,6 +14,10 @@ a { background-color: rgba(0, 0, 0, 0.1); } +.quote { + border-color: #c7ccd1; +} + .pre { background-color: #f9f9f9 !important; } diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css index d0760aa..a0973ae 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.css @@ -57,6 +57,13 @@ img { border-radius: 3px; } +.quote { + border-left: 4px solid; + border-radius: 3px; + margin: 8px 0; + padding-left: 10px; +} + .pre { font-family: "Consolas", "Courier New", Courier, monospace; }