-
-
Notifications
You must be signed in to change notification settings - Fork 6
XmlMarkupFormatter and self-closing tags #11
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
Comments
Sounds good. Can you share an example how you produced the original format - which is not round-trip preserved? Thanks! |
Here you go. Ideally it wouldn't be [Test]
public void test_xml()
{
var xmlDoc = new XmlParser().ParseDocument(
@"<Project Sdk=""Microsoft.NET.Sdk"">
<ItemGroup>
<PackageReference Include=""AngleSharp"" Version=""0.12.1"" />
<PackageReference Include=""AngleSharp.Xml"" Version=""0.12.1"" />
<PackageReference Include=""AngleSharp.XPath"" Version=""1.1.4"" />
</ItemGroup>
</Project>");
{
var sw = new StringWriter();
xmlDoc.ToHtml(sw, new XmlMarkupFormatter());
Console.WriteLine("BOO");
Console.WriteLine(sw.ToString());
Console.WriteLine();
}
{
var sw = new StringWriter();
xmlDoc.ToHtml(sw, new SelfClosingXmlMarkupFormatter());
Console.WriteLine("YAY");
Console.WriteLine(sw.ToString());
Console.WriteLine();
}
} |
I mean the most ideal would be Independent of the name - thanks for the example; I'll look into it! |
Yep, I've experienced the same drawbacks. They should call it |
Part of it landed in
What we miss so far is that an element that was declared as self-closing should be serialized as self-closing. For this, however, we require AngleSharp 0.14 - with a breaking change regarding the element construction from documents (allowing to set the respective |
Fully landed in |
Uh oh!
There was an error while loading. Please reload this page.
I can't see a way to choose self-closing tags.
The default format of many partially-human readable xml files e.g.
csproj
files, is to use self-closing tags. If you round trip a file throughXmlMarkupFormatter
then they will become uglified.I would appreciate an option to choose self-closing but ideally I would support changing the default to be self-closing because it produces shorter and more readable output and I have no use-case for the verbose form.
Here is my current work-around to wrap the
XmlMarkupFormatter
:The text was updated successfully, but these errors were encountered: