diff --git a/src/Docfx.Dotnet/Parsers/XmlComment.cs b/src/Docfx.Dotnet/Parsers/XmlComment.cs index 823e7a92c12..2406b90aa6f 100644 --- a/src/Docfx.Dotnet/Parsers/XmlComment.cs +++ b/src/Docfx.Dotnet/Parsers/XmlComment.cs @@ -112,6 +112,10 @@ public static XmlComment Parse(string xml, XmlCommentParserContext context = nul } try { + // Format xml with indentation. + // It's needed to fix issue (https://github.com/dotnet/docfx/issues/9736) + xml = XElement.Parse(xml).ToString(SaveOptions.None); + return new XmlComment(xml, context ?? new()); } catch (XmlException) diff --git a/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs b/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs index 698e3b910ab..37524281fb0 100644 --- a/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs +++ b/test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs @@ -28,8 +28,7 @@ public static void ParaNewLine() Assert.Equal( """ a -
b
-c
+b
c
""", XmlComment.Parse("""This is ref
a sample of exception node
public class XmlElement
- : XmlLinkedNode
- public class XmlElement
+ : XmlLinkedNode
+