Indent Closing Tag After Self-Closing Tag

Issue: #185
This commit is contained in:
Josh Johnson 2018-05-31 19:05:52 -04:00
parent 5a90a0c121
commit 0b892f6f03

View File

@ -169,7 +169,7 @@ export class V2XmlFormatter implements XmlFormatter {
indentLevel--;
// if the end tag immediately follows a line break, just add an indentation
// if the end tag immediately follows another end tag, add a line break and indent
// if the end tag immediately follows another end tag or a self-closing tag (issue #185), add a line break and indent
// otherwise, this should be treated as a same-line end tag(ex. <element>text</element>)
if (pc === "\n") {
output += `${this._getIndent(options, indentLevel)}<`;
@ -179,6 +179,10 @@ export class V2XmlFormatter implements XmlFormatter {
output += `${options.newLine}${this._getIndent(options, indentLevel)}<`;
}
else if (pc === ">" && ppc === "/") {
output += `${this._getIndent(options, indentLevel)}<`;
}
else {
output += "<";
}