Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow dash as tag name in markdig code snippet syntax #8783

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.DocAsCode.MarkdigEngine.Extensions;

public class CodeSnippetExtractor
{
private static readonly Regex TagnameFormat = new(@"^[\w\.]+$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex TagnameFormat = new(@"^[\w\.-]+$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly string StartLineTemplate;
private readonly string EndLineTemplate;
private readonly bool IsEndLineContainsTagName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void TestDfmFencesBlockLevel()
}

[Theory]
[Trait("Related", "DfmMarkdown")]
[Trait("Related", "DfmMarkdown")]
#region Inline Data
[InlineData(@"[!code-csharp[Main](Program.cs)]", @"<pre><code class=""lang-csharp"" name=""Main"">namespace ConsoleApplication1
{
Expand Down Expand Up @@ -609,6 +609,51 @@ public void TestDfmFencesBlockLevelWithWhitespaceLeading()
});
}

[Fact]
public void Issue8777()
{
TestUtility.VerifyMarkup(
"""
[!code-csharp[Main](Greet.cs?name=hello-world-message)]
""",
"""
<pre><code class="lang-csharp" name="Main">
namespace HelloWorld
{
public class Greet
{
public string Who { get; private set; }

public Greet(string who)
{
Who = who;
}
}
}</code></pre>
""",
files: new Dictionary<string, string>
{
{
"Greet.cs", """
#region hello-world-message
namespace HelloWorld
{
public class Greet
{
public string Who { get; private set; }

public Greet(string who)
{
Who = who;
}
}
}
#endregion
"""
},
});
}

[Fact]
[Trait("Related", "DfmMarkdown")]
public void TestDfmFencesBlockLevelWithWorkingFolder()
Expand Down