Pretty Self-Closing Tags

Issue: #149
This commit is contained in:
Josh Johnson 2018-05-29 21:56:29 -04:00
parent 07b47c4748
commit 156e1ab435
5 changed files with 25 additions and 0 deletions

View file

@ -135,6 +135,14 @@ export class V2XmlFormatter implements XmlFormatter {
location = Location.StartTag;
}
// approaching the end of a self-closing tag where there was no whitespace (issue #149)
else if ((location === Location.StartTag || location === Location.StartTagName)
&& cc === "/"
&& pc !== " "
&& options.enforcePrettySelfClosingTagOnFormat) {
output += " /";
}
// exiting StartTag or StartTag.StartTagName, entering Text
else if ((location === Location.StartTag || location === Location.StartTagName) && cc === ">") {
// if this was a self-closing tag, we need to decrement the indent level and add a newLine