From d68dbe8a223dfa0a62c54d7556c660492d8004bb Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Fri, 31 May 2019 23:10:43 -0400 Subject: [PATCH 1/3] Add Failing Test issue: #257 --- package-lock.json | 2 +- src/test/extension.test.ts | 6 +++++- src/test/test-data/issue-257.formatted.xml | 18 ++++++++++++++++++ src/test/test-data/issue-257.unformatted.xml | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/test/test-data/issue-257.formatted.xml create mode 100644 src/test/test-data/issue-257.unformatted.xml diff --git a/package-lock.json b/package-lock.json index fe9ebfa..4c3ea1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "xml", - "version": "2.3.2", + "version": "2.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 675aa6b..a4368e9 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -44,7 +44,7 @@ describe("V2XmlFormatter", () => { testFormatter(xmlFormatter, options, "preformatted"); }); - it ("should preserve line breaks between elements", () => { + it("should preserve line breaks between elements", () => { testFormatter(xmlFormatter, options, "preserve-breaks"); }); @@ -95,6 +95,10 @@ describe("V2XmlFormatter", () => { it("should not remove spaces between the node name and the first attribute within CDATA", () => { testFormatter(xmlFormatter, options, "issue-227"); }); + + it("should handle mixed content as a child of another element", () => { + testFormatter(xmlFormatter, options, "issue-257"); + }); }); }); diff --git a/src/test/test-data/issue-257.formatted.xml b/src/test/test-data/issue-257.formatted.xml new file mode 100644 index 0000000..f5992a9 --- /dev/null +++ b/src/test/test-data/issue-257.formatted.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + WARNING: Unmatched element: + + + + + \ No newline at end of file diff --git a/src/test/test-data/issue-257.unformatted.xml b/src/test/test-data/issue-257.unformatted.xml new file mode 100644 index 0000000..842df62 --- /dev/null +++ b/src/test/test-data/issue-257.unformatted.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + WARNING: Unmatched element: + + + + + \ No newline at end of file From fd40e6e18b1b665a398851206f8cf6bb3421b6a9 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Fri, 31 May 2019 23:15:59 -0400 Subject: [PATCH 2/3] Correct Test Data issue: #257 --- src/test/test-data/issue-257.formatted.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/test-data/issue-257.formatted.xml b/src/test/test-data/issue-257.formatted.xml index f5992a9..842df62 100644 --- a/src/test/test-data/issue-257.formatted.xml +++ b/src/test/test-data/issue-257.formatted.xml @@ -1,5 +1,6 @@ - + @@ -10,9 +11,9 @@ - WARNING: Unmatched element: + WARNING: Unmatched element: - + \ No newline at end of file From 66e2836708ec7e8a0c5ae20eb71f219d176a4715 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Sat, 1 Jun 2019 00:08:00 -0400 Subject: [PATCH 3/3] Don't Decrement Indent Level in Mixed Content issue: #257 --- src/formatting/formatters/v2-xml-formatter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/formatting/formatters/v2-xml-formatter.ts b/src/formatting/formatters/v2-xml-formatter.ts index d28a731..d38752d 100644 --- a/src/formatting/formatters/v2-xml-formatter.ts +++ b/src/formatting/formatters/v2-xml-formatter.ts @@ -224,7 +224,9 @@ export class V2XmlFormatter implements XmlFormatter { // entering EndTag else if (isLocation(Location.Text) && cc === "<" && nc === "/") { - indentLevel--; + if (!inMixedContent) { + indentLevel--; + } refreshMixedContentFlag();