forked from external/vscode-xml
		
	
						commit
						60cf5e34ce
					
				
					 2 changed files with 17 additions and 7 deletions
				
			
		| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
	"name": "xml",
 | 
						"name": "xml",
 | 
				
			||||||
	"displayName": "XML Tools",
 | 
						"displayName": "XML Tools",
 | 
				
			||||||
	"description": "XML Formatting, XQuery, and XPath Tools for Visual Studio Code",
 | 
						"description": "XML Formatting, XQuery, and XPath Tools for Visual Studio Code",
 | 
				
			||||||
	"version": "1.9.0",
 | 
						"version": "1.9.1",
 | 
				
			||||||
	"publisher": "DotJoshJohnson",
 | 
						"publisher": "DotJoshJohnson",
 | 
				
			||||||
	"author": {
 | 
						"author": {
 | 
				
			||||||
		"name": "Josh Johnson",
 | 
							"name": "Josh Johnson",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,20 +60,20 @@ export class XmlFormatter {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // <elm></elm>
 | 
					            // <elm></elm>
 | 
				
			||||||
            else if (/^<\w/.test(parts[i - 1]) && /^<\/\w/.test(parts[i])
 | 
					            else if (/^<(\w|:)/.test(parts[i - 1]) && /^<\/(\w|:)/.test(parts[i])
 | 
				
			||||||
                && /^<[\w:\-\.\,]+/.exec(parts[i - 1])[0] == /^<\/[\w:\-\.\,]+/.exec(parts[i])[0].replace('/', '')) {
 | 
					                && /^<[\w:\-\.\,\/ ]+/.exec(parts[i - 1])[0] == /^<\/[\w:\-\.\, ]+/.exec(parts[i])[0].replace('/', '')) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                output += parts[i];
 | 
					                output += parts[i];
 | 
				
			||||||
                if (!inComment) level--;
 | 
					                if (!inComment) level--;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // <elm>
 | 
					            // <elm>
 | 
				
			||||||
            else if (parts[i].search(/<\w/) > -1 && parts[i].search(/<\//) == -1 && parts[i].search(/\/>/) == -1) {
 | 
					            else if (parts[i].search(/<(\w|:)/) > -1 && parts[i].search(/<\//) == -1 && parts[i].search(/\/>/) == -1) {
 | 
				
			||||||
                output = (!inComment) ? output += this._getIndent(level++, parts[i]) : output += parts[i];
 | 
					                output = (!inComment) ? output += this._getIndent(level++, parts[i]) : output += parts[i];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // <elm>...</elm>
 | 
					            // <elm>...</elm>
 | 
				
			||||||
            else if (parts[i].search(/<\w/) > -1 && parts[i].search(/<\//) > -1) {
 | 
					            else if (parts[i].search(/<(\w|:)/) > -1 && parts[i].search(/<\//) > -1) {
 | 
				
			||||||
                output = (!inComment) ? output += this._getIndent(level, parts[i]) : output += parts[i];
 | 
					                output = (!inComment) ? output += this._getIndent(level, parts[i]) : output += parts[i];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					@ -83,12 +83,12 @@ export class XmlFormatter {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // <elm />
 | 
					            // <elm />
 | 
				
			||||||
            else if (parts[i].search(/\/>/) > -1 && (!this.splitNamespaces || parts[i].search(/xmlns\:/) == -1)) {
 | 
					            else if (parts[i].search(/\/>/) > -1 && (!this.splitNamespaces || parts[i].search(/xmlns(:|=)/) == -1)) {
 | 
				
			||||||
                output = (!inComment) ? output += this._getIndent(level, parts[i]) : output += parts[i];
 | 
					                output = (!inComment) ? output += this._getIndent(level, parts[i]) : output += parts[i];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // xmlns />
 | 
					            // xmlns />
 | 
				
			||||||
            else if (parts[i].search(/\/>/) > -1 && parts[i].search(/xmlns\:/) > -1 && this.splitNamespaces) {
 | 
					            else if (parts[i].search(/\/>/) > -1 && parts[i].search(/xmlns(:|=)/) > -1 && this.splitNamespaces) {
 | 
				
			||||||
                output = (!inComment) ? output += this._getIndent(level--, parts[i]) : output += parts[i];
 | 
					                output = (!inComment) ? output += this._getIndent(level--, parts[i]) : output += parts[i];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					@ -152,6 +152,8 @@ export class XmlFormatter {
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        for (let i = 0; i < xml.length; i++) {
 | 
					        for (let i = 0; i < xml.length; i++) {
 | 
				
			||||||
            let char: string = xml.charAt(i);
 | 
					            let char: string = xml.charAt(i);
 | 
				
			||||||
 | 
					            let prev: string = xml.charAt(i - 1);
 | 
				
			||||||
 | 
					            let next: string = xml.charAt(i + 1);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if (char == '!' && (xml.substr(i, 8) == '![CDATA[' || xml.substr(i, 3) == '!--')) {
 | 
					            if (char == '!' && (xml.substr(i, 8) == '![CDATA[' || xml.substr(i, 3) == '!--')) {
 | 
				
			||||||
                inCdata = true;
 | 
					                inCdata = true;
 | 
				
			||||||
| 
						 | 
					@ -166,6 +168,14 @@ export class XmlFormatter {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            else if (char.search(/[\r\n]/g) > -1 && !inCdata) {
 | 
					            else if (char.search(/[\r\n]/g) > -1 && !inCdata) {
 | 
				
			||||||
 | 
					                if (/\r/.test(char) && /\S|\r|\n/.test(prev) && /\S|\r|\n/.test(xml.charAt(i + this.newLine.length))) {
 | 
				
			||||||
 | 
					                    output += char;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                else if (/\n/.test(char) && /\S|\r|\n/.test(xml.charAt(i - this.newLine.length)) && /\S|\r|\n/.test(next)) {
 | 
				
			||||||
 | 
					                    output += char;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue