From 2f7c1e7ebf4bfdaab54138a19522cbe86d0c0cb1 Mon Sep 17 00:00:00 2001 From: Yufei Huang Date: Wed, 12 Apr 2023 10:00:53 +0800 Subject: [PATCH 1/2] fix: angle bracket escape in code inline --- samples/seed/dotnet/project/Project/Class1.cs | 2 ++ src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs | 4 ++-- test/Microsoft.DocAsCode.Dotnet.Tests/XmlCommentUnitTest.cs | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/samples/seed/dotnet/project/Project/Class1.cs b/samples/seed/dotnet/project/Project/Class1.cs index fbf4234f6c0..281f63c89b1 100644 --- a/samples/seed/dotnet/project/Project/Class1.cs +++ b/samples/seed/dotnet/project/Project/Class1.cs @@ -79,6 +79,8 @@ public void Issue2623() { } /// > [!NOTE] /// > This is a <note>. & " ' /// + /// Inline `<angle brackets>`. + /// /// [link](https://www.github.com "title") /// /// ```csharp diff --git a/src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs b/src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs index f96c5c28157..7308f0a48fa 100644 --- a/src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs +++ b/src/Microsoft.DocAsCode.Dotnet/Parsers/XmlComment.cs @@ -569,7 +569,7 @@ static void DecodeMarkdownCode(MarkdownObject node) switch (node) { case CodeInline codeInline: - codeInline.Content = XmlDecode(codeInline.Content); + codeInline.ContentWithTrivia = new(XmlDecode(codeInline.ContentWithTrivia.ToString()), codeInline.ContentWithTrivia.NewLine); break; case CodeBlock codeBlock: @@ -577,7 +577,7 @@ static void DecodeMarkdownCode(MarkdownObject node) foreach (var line in codeBlock.Lines.Lines) { var newLine = line; - newLine.Slice = new StringSlice(XmlDecode(line.Slice.ToString()), line.Slice.NewLine); + newLine.Slice = new(XmlDecode(line.Slice.ToString()), line.Slice.NewLine); lines.Add(newLine); } codeBlock.Lines = lines; diff --git a/test/Microsoft.DocAsCode.Dotnet.Tests/XmlCommentUnitTest.cs b/test/Microsoft.DocAsCode.Dotnet.Tests/XmlCommentUnitTest.cs index a8e13561ede..c95b8b6ab15 100644 --- a/test/Microsoft.DocAsCode.Dotnet.Tests/XmlCommentUnitTest.cs +++ b/test/Microsoft.DocAsCode.Dotnet.Tests/XmlCommentUnitTest.cs @@ -199,6 +199,12 @@ function main() """, comment.Remarks, ignoreLineEndingDifferences: true); } + [Fact] + public static void MarkdownCodeInline() + { + Verify("Inline `<angle brackets>`", "Inline ``"); + } + [Fact] public void TestXmlCommentParser() { From 8f8b27a7c263fd8cc89036990357ddf9a16210c6 Mon Sep 17 00:00:00 2001 From: yufeih Date: Wed, 12 Apr 2023 02:08:20 +0000 Subject: [PATCH 2/2] test(snapshot): update snapshots for 42daa62a3a73ffd78be504ee59043e5c7bf44fea --- .../BuildFromProject.Class1.html.view.verified.json | 10 +++++----- .../SamplesTest.Seed/index.verified.json | 2 +- .../api-BuildFromProject.Class1.html.verified.png | 4 ++-- .../api-BuildFromProject.Class1.html.verified.png | 4 ++-- .../api-BuildFromProject.Class1.html.verified.html | 5 +++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/docfx.Snapshot.Tests/SamplesTest.Seed/api/BuildFromProject.Class1.html.view.verified.json b/test/docfx.Snapshot.Tests/SamplesTest.Seed/api/BuildFromProject.Class1.html.view.verified.json index 178793c1605..0fc77681534 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.Seed/api/BuildFromProject.Class1.html.view.verified.json +++ b/test/docfx.Snapshot.Tests/SamplesTest.Seed/api/BuildFromProject.Class1.html.view.verified.json @@ -389,7 +389,7 @@ }, "id": "Issue2723", "path": "dotnet/project/Project/Class1.cs", - "startLine": 92.0, + "startLine": 94.0, "endLine": 0.0, "isExternal": false }, @@ -397,7 +397,7 @@ "BuildFromProject" ], "namespace": "BuildFromProject", - "remarks": "
\n
Note
\n

This is a <note>. & " '

\n
\n

link

\n
for (var i = 0; i > 10; i++) // & " '\nvar range = new Range<int> { Min = 0, Max = 10 };\n
\n
var range = new Range<int> { Min = 0, Max = 10 };
\n", + "remarks": "
\n
Note
\n

This is a <note>. & " '

\n
\n

Inline <angle brackets>.

\n

link

\n
for (var i = 0; i > 10; i++) // & " '\nvar range = new Range<int> { Min = 0, Max = 10 };\n
\n
var range = new Range<int> { Min = 0, Max = 10 };
\n", "example": [], "overload": { "uid": "BuildFromProject.Class1.Issue2723*", @@ -448,7 +448,7 @@ "summary": "", "platform": null, "docurl": "https://github.com/dotnet/docfx/new/main/apiSpec/new?filename=BuildFromProject_Class1_Issue2723.md&value=---%0Auid%3A%20BuildFromProject.Class1.Issue2723%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A", - "sourceurl": "https://github.com/dotnet/docfx/blob/main/samples/seed/dotnet/project/Project/Class1.cs/#L93", + "sourceurl": "https://github.com/dotnet/docfx/blob/main/samples/seed/dotnet/project/Project/Class1.cs/#L95", "conceptual": "", "implements": "", "seealso": null, @@ -657,7 +657,7 @@ }, "id": "Issue4392", "path": "dotnet/project/Project/Class1.cs", - "startLine": 97.0, + "startLine": 99.0, "endLine": 0.0, "isExternal": false }, @@ -716,7 +716,7 @@ "summary": "", "platform": null, "docurl": "https://github.com/dotnet/docfx/new/main/apiSpec/new?filename=BuildFromProject_Class1_Issue4392.md&value=---%0Auid%3A%20BuildFromProject.Class1.Issue4392%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A", - "sourceurl": "https://github.com/dotnet/docfx/blob/main/samples/seed/dotnet/project/Project/Class1.cs/#L98", + "sourceurl": "https://github.com/dotnet/docfx/blob/main/samples/seed/dotnet/project/Project/Class1.cs/#L100", "conceptual": "", "implements": "", "seealso": null, diff --git a/test/docfx.Snapshot.Tests/SamplesTest.Seed/index.verified.json b/test/docfx.Snapshot.Tests/SamplesTest.Seed/index.verified.json index ef4ba50d1e6..1904ba14d67 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.Seed/index.verified.json +++ b/test/docfx.Snapshot.Tests/SamplesTest.Seed/index.verified.json @@ -22,7 +22,7 @@ "api/BuildFromProject.Class1.html": { "href": "api/BuildFromProject.Class1.html", "title": "Class Class1 | docfx seed website", - "keywords": "Class Class1 Namespace BuildFromProject Assembly BuildFromProject.dll public class Class1 Inheritance object Class1 Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() Methods Issue1651() Pricing models are used to calculate theoretical option values 1Black Scholes 2Black76 3Black76Fut 4Equity Tree 5Variance Swap 6Dividend Forecast public void Issue1651() Issue2623() public void Issue2623() Examples MyClass myClass = new MyClass(); void Update() { myClass.Execute(); } Remarks For example: MyClass myClass = new MyClass(); void Update() { myClass.Execute(); } Issue2723() public void Issue2723() Remarks Note This is a . & \" ' link for (var i = 0; i > 10; i++) // & \" ' var range = new Range { Min = 0, Max = 10 }; var range = new Range { Min = 0, Max = 10 }; Issue4017() public void Issue4017() Examples public void HookMessageDeleted(BaseSocketClient client) { client.MessageDeleted += HandleMessageDelete; } public Task HandleMessageDelete(Cacheable cachedMessage, ISocketMessageChannel channel) { // check if the message exists in cache; if not, we cannot report what was removed if (!cachedMessage.HasValue) return; var message = cachedMessage.Value; Console.WriteLine($\"A message ({message.Id}) from {message.Author} was removed from the channel {channel.Name} ({channel.Id}):\" + Environment.NewLine + message.Content); return Task.CompletedTask; } Remarks void Update() { myClass.Execute(); } Issue4392() public void Issue4392() Remarks @\"\\\\?\\\" @\"\\\\?\\\" Issue7484() public void Issue7484() Remarks There's really no reason to not believe that this class can test things. Term Description A Term A Description Bee Term Bee Description Issue896() Test public void Issue896() See Also Class1.Test XmlCommentIncludeTag() This method should do something... public void XmlCommentIncludeTag() Remarks This is remarks." + "keywords": "Class Class1 Namespace BuildFromProject Assembly BuildFromProject.dll public class Class1 Inheritance object Class1 Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() Methods Issue1651() Pricing models are used to calculate theoretical option values 1Black Scholes 2Black76 3Black76Fut 4Equity Tree 5Variance Swap 6Dividend Forecast public void Issue1651() Issue2623() public void Issue2623() Examples MyClass myClass = new MyClass(); void Update() { myClass.Execute(); } Remarks For example: MyClass myClass = new MyClass(); void Update() { myClass.Execute(); } Issue2723() public void Issue2723() Remarks Note This is a . & \" ' Inline . link for (var i = 0; i > 10; i++) // & \" ' var range = new Range { Min = 0, Max = 10 }; var range = new Range { Min = 0, Max = 10 }; Issue4017() public void Issue4017() Examples public void HookMessageDeleted(BaseSocketClient client) { client.MessageDeleted += HandleMessageDelete; } public Task HandleMessageDelete(Cacheable cachedMessage, ISocketMessageChannel channel) { // check if the message exists in cache; if not, we cannot report what was removed if (!cachedMessage.HasValue) return; var message = cachedMessage.Value; Console.WriteLine($\"A message ({message.Id}) from {message.Author} was removed from the channel {channel.Name} ({channel.Id}):\" + Environment.NewLine + message.Content); return Task.CompletedTask; } Remarks void Update() { myClass.Execute(); } Issue4392() public void Issue4392() Remarks @\"\\\\?\\\" @\"\\\\?\\\" Issue7484() public void Issue7484() Remarks There's really no reason to not believe that this class can test things. Term Description A Term A Description Bee Term Bee Description Issue896() Test public void Issue896() See Also Class1.Test XmlCommentIncludeTag() This method should do something... public void XmlCommentIncludeTag() Remarks This is remarks." }, "api/BuildFromProject.Class1.Test-1.html": { "href": "api/BuildFromProject.Class1.Test-1.html", diff --git a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/1920x1080/api-BuildFromProject.Class1.html.verified.png b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/1920x1080/api-BuildFromProject.Class1.html.verified.png index bb0dc737a37..033b2b60a45 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/1920x1080/api-BuildFromProject.Class1.html.verified.png +++ b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/1920x1080/api-BuildFromProject.Class1.html.verified.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec79d85348e698c299fc3761acb023ffaa11e12d1109201fc599b7740ab689ba -size 420971 +oid sha256:2cb5d77a37fe9075acaab370172dd2a0c5c079157fd218bf181f4f386de29980 +size 424361 diff --git a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/375x812/api-BuildFromProject.Class1.html.verified.png b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/375x812/api-BuildFromProject.Class1.html.verified.png index b2ca3007eca..619a9405c8a 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/375x812/api-BuildFromProject.Class1.html.verified.png +++ b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/375x812/api-BuildFromProject.Class1.html.verified.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2700e3a563ffb6f8721c4e2358db8cd1b544e0b9895b30b3bc631bf62d26cd18 -size 283151 +oid sha256:a29e47147a8a44140e53a3cb525d74aed8a36f58707107134c0b33a63a5f715a +size 286009 diff --git a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/html/api-BuildFromProject.Class1.html.verified.html b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/html/api-BuildFromProject.Class1.html.verified.html index 4af51b1341c..fea471e2a86 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/html/api-BuildFromProject.Class1.html.verified.html +++ b/test/docfx.Snapshot.Tests/SamplesTest.SeedHtml/html/api-BuildFromProject.Class1.html.verified.html @@ -611,7 +611,7 @@

Remarks Issue2723() - +

@@ -634,6 +634,7 @@

RemarksNote

This is a <note>. & " '

+

Inline <angle brackets>.

link

for (var i = 0; i > 10; i++) // & " '
 var range = new Range<int> { Min = 0, Max = 10 };
@@ -697,7 +698,7 @@ 

Remarks Issue4392() - +