Merge pull request #324 from DotJoshJohnson/bug/288-trailing-whitespace

Trim Trailing Whitespace from Split Attributes
This commit is contained in:
Josh Johnson 2020-07-08 23:11:40 -04:00 committed by GitHub
commit 5af8142204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 2 deletions

View File

@ -163,6 +163,10 @@ export class V2XmlFormatter implements XmlFormatter {
&& ((options.splitXmlnsOnFormat
&& xml.substr(i, 5).toLowerCase() === "xmlns")
|| 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)}`;
}

View File

@ -103,6 +103,10 @@ describe("V2XmlFormatter", () => {
it("should not touch CDATA content", () => {
testFormatter(xmlFormatter, options, "issue-293");
});
it("should not add trailing whitespace", () => {
testFormatter(xmlFormatter, options, "issue-288");
});
});
describe("#minifyXml(xml, options)", () => {

View 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>

View 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>