Omit Extraneous Pre-Start Tag Line Breaks

Issue: #178
This commit is contained in:
Josh Johnson 2018-05-29 19:41:42 -04:00
parent b65009728c
commit af2060dc38
1 changed files with 3 additions and 1 deletions

View File

@ -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)}<`;
}