Merge pull request #324 from DotJoshJohnson/bug/288-trailing-whitespace
Trim Trailing Whitespace from Split Attributes
This commit is contained in:
		
						commit
						5af8142204
					
				
					 6 changed files with 32 additions and 2 deletions
				
			
		| 
						 | 
					@ -163,6 +163,10 @@ export class V2XmlFormatter implements XmlFormatter {
 | 
				
			||||||
                    && ((options.splitXmlnsOnFormat
 | 
					                    && ((options.splitXmlnsOnFormat
 | 
				
			||||||
                        && xml.substr(i, 5).toLowerCase() === "xmlns")
 | 
					                        && xml.substr(i, 5).toLowerCase() === "xmlns")
 | 
				
			||||||
                        || options.splitAttributesOnFormat)) {
 | 
					                        || options.splitAttributesOnFormat)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // trim the end of output here to ensure there is no trailing whitespace (issue #288)
 | 
				
			||||||
 | 
					                    output = this._removeTrailingNonBreakingWhitespace(output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    output += `${options.newLine}${this._getIndent(options, indentLevel)}`;
 | 
					                    output += `${options.newLine}${this._getIndent(options, indentLevel)}`;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,6 +103,10 @@ describe("V2XmlFormatter", () => {
 | 
				
			||||||
        it("should not touch CDATA content", () => {
 | 
					        it("should not touch CDATA content", () => {
 | 
				
			||||||
            testFormatter(xmlFormatter, options, "issue-293");
 | 
					            testFormatter(xmlFormatter, options, "issue-293");
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        it("should not add trailing whitespace", () => {
 | 
				
			||||||
 | 
					            testFormatter(xmlFormatter, options, "issue-288");
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    describe("#minifyXml(xml, options)", () => {
 | 
					    describe("#minifyXml(xml, options)", () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								src/test/test-data/issue-288.formatted.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/test/test-data/issue-288.formatted.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,11 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 | 
				
			||||||
 | 
					    xmlns="http://purl.org/rss/1.0/"
 | 
				
			||||||
 | 
					    xmlns:content="http://purl.org/rss/1.0/modules/content/"
 | 
				
			||||||
 | 
					    xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
 | 
				
			||||||
 | 
					    xmlns:dc="http://purl.org/dc/elements/1.1/"
 | 
				
			||||||
 | 
					    xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
 | 
				
			||||||
 | 
					    xmlns:admin="http://webns.net/mvcb/">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</rdf:RDF>
 | 
				
			||||||
							
								
								
									
										11
									
								
								src/test/test-data/issue-288.unformatted.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/test/test-data/issue-288.unformatted.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,11 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 | 
				
			||||||
 | 
					    xmlns="http://purl.org/rss/1.0/"
 | 
				
			||||||
 | 
					    xmlns:content="http://purl.org/rss/1.0/modules/content/"
 | 
				
			||||||
 | 
					    xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
 | 
				
			||||||
 | 
					    xmlns:dc="http://purl.org/dc/elements/1.1/"
 | 
				
			||||||
 | 
					    xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
 | 
				
			||||||
 | 
					    xmlns:admin="http://webns.net/mvcb/">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</rdf:RDF>
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue