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 through XmlMarkupFormatter
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
:
public class SelfClosingXmlMarkupFormatter : IMarkupFormatter { public string Text(ICharacterData text) => XmlMarkupFormatter.Instance.Text(text); public string Comment(IComment comment) => XmlMarkupFormatter.Instance.Comment(comment); public string Processing(IProcessingInstruction processing) => XmlMarkupFormatter.Instance.Processing(processing); public string Doctype(IDocumentType doctype) => XmlMarkupFormatter.Instance.Doctype(doctype); public string OpenTag(IElement element, bool selfClosing) => XmlMarkupFormatter.Instance.OpenTag(element, !(element.HasChildNodes || element.HasTextNodes())); public string CloseTag(IElement element, bool selfClosing) => XmlMarkupFormatter.Instance.CloseTag(element, !(element.HasChildNodes || element.HasTextNodes())); public string Attribute(IAttr attribute) => XmlMarkupFormatter.Instance.Attribute(attribute); }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4