From dd0a35838d0efcaaa0e29a685e54a7ae320f4fff Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sat, 5 Aug 2023 18:30:11 +0300 Subject: [PATCH] Allow empty lines in repeated single-line quote nodes Closes #1115 --- DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs b/DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs index a1014321..ca1282db 100644 --- a/DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs +++ b/DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs @@ -12,7 +12,7 @@ namespace DiscordChatExporter.Core.Markdown.Parsing; // Discord does NOT use a recursive-descent parser for markdown which becomes evident in some // scenarios, like when multiple formatting nodes are nested together. // To replicate Discord's behavior, we're employing a special parser that uses a set of regular -// expressions that are executed sequentially in a first-match-first-serve manner. +// expressions that are executed sequentially in a first-matched-first-served manner. internal static partial class MarkdownParser { private const RegexOptions DefaultRegexOptions = @@ -83,7 +83,9 @@ internal static partial class MarkdownParser private static readonly IMatcher RepeatedSingleLineQuoteNodeMatcher = new RegexMatcher( // Include the linebreaks in the content, so that the lines are preserved in quotes. - new Regex(@"(?:^>\s(.+\n?)){2,}", DefaultRegexOptions), + // Empty content is allowed within quotes. + // https://github.com/Tyrrrz/DiscordChatExporter/issues/1115 + new Regex(@"(?:^>\s(.*\n?)){2,}", DefaultRegexOptions), (s, m) => new FormattingNode( FormattingKind.Quote, m.Groups[1].Captures.SelectMany(c => Parse(s.Relocate(c))).ToArray()