From 9b6de3c765f48a58e0cd33b26f40107e1c2cb65e Mon Sep 17 00:00:00 2001 From: vwxyzh Date: Wed, 18 Jan 2017 19:43:59 -0800 Subject: [PATCH] fix region support for code snippets broken by end region with extra text. --- .../TagNameBlockPathQueryOption.cs | 4 ++-- .../DocfxFlavoredMarkdownTest.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.DocAsCode.Dfm/DfmFencesBlockPathQueryOptions/TagNameBlockPathQueryOption.cs b/src/Microsoft.DocAsCode.Dfm/DfmFencesBlockPathQueryOptions/TagNameBlockPathQueryOption.cs index dc3701c88a7..0801ffbf964 100644 --- a/src/Microsoft.DocAsCode.Dfm/DfmFencesBlockPathQueryOptions/TagNameBlockPathQueryOption.cs +++ b/src/Microsoft.DocAsCode.Dfm/DfmFencesBlockPathQueryOptions/TagNameBlockPathQueryOption.cs @@ -20,7 +20,7 @@ public class TagNameBlockPathQueryOption : DfmFencesBlockPathQueryOption // C# code snippet region block: start -> #region snippetname, end -> #endregion private static readonly Regex CSharpCodeSnippetRegionStartLineRegex = new Regex(@"^\s*#\s*region\s+(?.+?)\s*$", RegexOptions.Compiled); - private static readonly Regex CSharpCodeSnippetRegionEndLineRegex = new Regex(@"^\s*#\s*endregion\s*$", RegexOptions.Compiled); + private static readonly Regex CSharpCodeSnippetRegionEndLineRegex = new Regex(@"^\s*#\s*endregion(?:\s.*)?$", RegexOptions.Compiled); // VB code snippet comment block: ' <[/]snippetname> private static readonly Regex VBCodeSnippetCommentStartLineRegex = new Regex(@"^\s*\'\s*\<\s*(?[\w\.]+)\s*\>\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -28,7 +28,7 @@ public class TagNameBlockPathQueryOption : DfmFencesBlockPathQueryOption // VB code snippet Region block: start -> # Region "snippetname", end -> # End Region private static readonly Regex VBCodeSnippetRegionRegionStartLineRegex = new Regex(@"^\s*#\s*Region\s*(?.+?)\s*$", RegexOptions.Compiled); - private static readonly Regex VBCodeSnippetRegionRegionEndLineRegex = new Regex(@"^\s*#\s*End\s+Region\s*$", RegexOptions.Compiled); + private static readonly Regex VBCodeSnippetRegionRegionEndLineRegex = new Regex(@"^\s*#\s*End\s+Region(?:\s.*)?$", RegexOptions.Compiled); // C++ code snippet block: // <[/]snippetname> private static readonly Regex CPlusPlusCodeSnippetCommentStartLineRegex = new Regex(@"^\s*\/{2}\s*\<\s*(?[\w\.]+)\s*\>\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); diff --git a/test/Microsoft.DocAsCode.Dfm.Tests/DocfxFlavoredMarkdownTest.cs b/test/Microsoft.DocAsCode.Dfm.Tests/DocfxFlavoredMarkdownTest.cs index c5c614a9d2b..ee328c922db 100644 --- a/test/Microsoft.DocAsCode.Dfm.Tests/DocfxFlavoredMarkdownTest.cs +++ b/test/Microsoft.DocAsCode.Dfm.Tests/DocfxFlavoredMarkdownTest.cs @@ -976,7 +976,7 @@ internal static class Helper public static void Foo() { } - #endregion + #endregion Foo } #endregion } @@ -1002,7 +1002,7 @@ internal static class Helper public static void Foo() { } - #endregion + #endregion Foo } #endregion } @@ -1101,7 +1101,7 @@ internal static class Helper public static void Foo() { } - #endregion + #endregion Foo } #endregion } @@ -1166,7 +1166,7 @@ internal static class Helper public static void Foo() { } - #endregion + #endregion Foo } #endregion } @@ -1222,7 +1222,7 @@ internal static class Helper public static void Foo() { } - #endregion + #endregion Foo } #endregion }";