From 2a02894d643577a5288dc8384fdf7fae188b576e Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Wed, 22 Apr 2020 19:23:56 +0300 Subject: [PATCH] [HTML] Fix weird inline code block behavior with two backticks --- DiscordChatExporter.Domain/Markdown/MarkdownParser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Domain/Markdown/MarkdownParser.cs b/DiscordChatExporter.Domain/Markdown/MarkdownParser.cs index af500a61..13cf6ccc 100644 --- a/DiscordChatExporter.Domain/Markdown/MarkdownParser.cs +++ b/DiscordChatExporter.Domain/Markdown/MarkdownParser.cs @@ -84,8 +84,8 @@ namespace DiscordChatExporter.Domain.Markdown // Blank lines at the beginning and end of content are trimmed // There can be either one or two backticks, but equal number on both sides private static readonly IMatcher InlineCodeBlockNodeMatcher = new RegexMatcher( - new Regex("`([^`]+)`", DefaultRegexOptions | RegexOptions.Singleline), - m => new InlineCodeBlockNode(m.Groups[1].Value.Trim('\r', '\n'))); + new Regex("(`{1,2})([^`]+)\\1", DefaultRegexOptions | RegexOptions.Singleline), + m => new InlineCodeBlockNode(m.Groups[2].Value.Trim('\r', '\n'))); // Capture language identifier and then any character until the earliest triple backtick // Language identifier is one word immediately after opening backticks, followed immediately by newline