[HTML] Fix repeated single quotes behavior with nested formatting

Closes #288
pull/321/head
Alexey Golub 5 years ago
parent 9711a8cca4
commit de9e7caaeb

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using DiscordChatExporter.Core.Markdown.Ast; using DiscordChatExporter.Core.Markdown.Ast;
@ -63,13 +64,13 @@ namespace DiscordChatExporter.Core.Markdown
(p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Slice(m.Groups[1])))); (p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Slice(m.Groups[1]))));
// Repeatedly capture any character until the end of the line // Repeatedly capture any character until the end of the line
// This one is tricky as it ends up producing multiple separate captures // This one is tricky as it ends up producing multiple separate captures which need to be joined
private static readonly IMatcher<Node> RepeatedSingleLineQuoteNodeMatcher = new RegexMatcher<Node>( private static readonly IMatcher<Node> RepeatedSingleLineQuoteNodeMatcher = new RegexMatcher<Node>(
new Regex("(?:^>\\s(.+\n?)){2,}", DefaultRegexOptions), new Regex("(?:^>\\s(.+\n?)){2,}", DefaultRegexOptions),
(p, m) => (p, m) =>
{ {
var children = m.Groups[1].Captures.Select(c => c.Value).SelectMany(Parse).ToArray(); var content = string.Concat(m.Groups[1].Captures.Select(c => c.Value));
return new FormattedNode(TextFormatting.Quote, children); return new FormattedNode(TextFormatting.Quote, Parse(content));
}); });
// Capture any character until the end of the input // Capture any character until the end of the input

Loading…
Cancel
Save