diff --git a/src/formatting/formatters/v2-xml-formatter.ts b/src/formatting/formatters/v2-xml-formatter.ts index 5f31514..647080f 100644 --- a/src/formatting/formatters/v2-xml-formatter.ts +++ b/src/formatting/formatters/v2-xml-formatter.ts @@ -39,6 +39,7 @@ export class V2XmlFormatter implements XmlFormatter { const nc = xml.charAt(i + 1); const nnc = xml.charAt(i + 2); const pc = xml.charAt(i - 1); + const ppc = xml.charAt(i - 2); // entering CData if (location === Location.Text && cc === "<" && nc === "!" && nnc === "[") { @@ -86,7 +87,8 @@ export class V2XmlFormatter implements XmlFormatter { // entering StartTag.StartTagName else if (location === Location.Text && cc === "<" && ["/", "!"].indexOf(nc) === -1) { // if this occurs after another tag, prepend a line break - if (pc === ">") { + // but do not add one if the previous tag was self-closing (it already adds its own) + if (pc === ">" && ppc !== "/") { output += `${options.newLine}${this._getIndent(options, indentLevel)}<`; }