From ab84ca3997870b1cb2e159bd3c6d62d972d13805 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Fri, 20 Nov 2020 13:02:32 +0000 Subject: [PATCH] Exclude matching \r\n When generating docs locally I noticed that some of the callouts only included a newline and were missing the carriage return. Upon investigation, I found that the regex used for callout replacement was catching and removing the \r character. This change fixes the two places such replacement may occur and ensures we stop matching before the \r\n. --- src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs | 2 +- src/DocGenerator/Documentation/Blocks/CSharpBlock.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs b/src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs index b9f7b9d8391..bf103592b76 100644 --- a/src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs +++ b/src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs @@ -198,7 +198,7 @@ public override void VisitSource(Source source) // Replace tabs with spaces and remove C# comment escaping from callouts // (elastic docs generation does not like this callout format) - source.Text = Regex.Replace(source.Text.Replace("\t", " "), @"//[ \t]*\<(\d+)\>.*", "<$1>"); + source.Text = Regex.Replace(source.Text.Replace("\t", " "), @"//[ \t]*\<(\d+)\>[^\r\n]*", "<$1>"); base.VisitSource(source); } diff --git a/src/DocGenerator/Documentation/Blocks/CSharpBlock.cs b/src/DocGenerator/Documentation/Blocks/CSharpBlock.cs index 2aefd6a1986..d588b2670b7 100644 --- a/src/DocGenerator/Documentation/Blocks/CSharpBlock.cs +++ b/src/DocGenerator/Documentation/Blocks/CSharpBlock.cs @@ -14,7 +14,7 @@ namespace DocGenerator.Documentation.Blocks public class CSharpBlock : CodeBlock { private static readonly Regex Callout = new Regex(@"//[ \t]*(?\<\d+\>)[ \t]*(?\S.*)", RegexOptions.Compiled); - private static readonly Regex CalloutReplacer = new Regex(@"//[ \t]*\<(\d+)\>.*", RegexOptions.Compiled); + private static readonly Regex CalloutReplacer = new Regex(@"//[ \t]*\<(\d+)\>[^\r\n]*", RegexOptions.Compiled); public CSharpBlock(SyntaxNode node, int depth, string memberName = null) : base(node.WithoutLeadingTrivia().ToFullStringWithoutPragmaWarningDirectiveTrivia(),