Skip to content

Commit a74c510

Browse files
authored
Exclude matching \r\n (#5111)
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.
1 parent 3d123cf commit a74c510

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public override void VisitSource(Source source)
198198

199199
// Replace tabs with spaces and remove C# comment escaping from callouts
200200
// (elastic docs generation does not like this callout format)
201-
source.Text = Regex.Replace(source.Text.Replace("\t", " "), @"//[ \t]*\<(\d+)\>.*", "<$1>");
201+
source.Text = Regex.Replace(source.Text.Replace("\t", " "), @"//[ \t]*\<(\d+)\>[^\r\n]*", "<$1>");
202202

203203
base.VisitSource(source);
204204
}

src/DocGenerator/Documentation/Blocks/CSharpBlock.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace DocGenerator.Documentation.Blocks
1414
public class CSharpBlock : CodeBlock
1515
{
1616
private static readonly Regex Callout = new Regex(@"//[ \t]*(?<callout>\<\d+\>)[ \t]*(?<text>\S.*)", RegexOptions.Compiled);
17-
private static readonly Regex CalloutReplacer = new Regex(@"//[ \t]*\<(\d+)\>.*", RegexOptions.Compiled);
17+
private static readonly Regex CalloutReplacer = new Regex(@"//[ \t]*\<(\d+)\>[^\r\n]*", RegexOptions.Compiled);
1818

1919
public CSharpBlock(SyntaxNode node, int depth, string memberName = null)
2020
: base(node.WithoutLeadingTrivia().ToFullStringWithoutPragmaWarningDirectiveTrivia(),

0 commit comments

Comments
 (0)