Skip to content

Commit

Permalink
Exclude matching \r\n (#5111) (#5113)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
github-actions[bot] and stevejgordon authored Nov 23, 2020
1 parent 900088a commit 3113731
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DocGenerator/Documentation/Blocks/CSharpBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DocGenerator.Documentation.Blocks
public class CSharpBlock : CodeBlock
{
private static readonly Regex Callout = new Regex(@"//[ \t]*(?<callout>\<\d+\>)[ \t]*(?<text>\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(),
Expand Down

0 comments on commit 3113731

Please sign in to comment.