Skip to content

Commit a07c501

Browse files
Exclude matching \r\n (#5111) (#5112)
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. Co-authored-by: Steve Gordon <[email protected]>
1 parent 0a1bf15 commit a07c501

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
@@ -197,7 +197,7 @@ public override void VisitSource(Source source)
197197

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

202202
base.VisitSource(source);
203203
}

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)