Merge pull request #276 from DotJoshJohnson/bug/issue-257

Fix Issue 257
This commit is contained in:
Josh Johnson 2019-06-01 00:24:20 -04:00 committed by GitHub
commit a156dd7df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 3 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "xml",
"version": "2.3.2",
"version": "2.4.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -224,7 +224,9 @@ export class V2XmlFormatter implements XmlFormatter {
// entering EndTag
else if (isLocation(Location.Text) && cc === "<" && nc === "/") {
indentLevel--;
if (!inMixedContent) {
indentLevel--;
}
refreshMixedContentFlag();

View File

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

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<file>
<xsl:apply-templates />
</file>
</xsl:template>
<xsl:template match="*">
<xsl:message terminate="no">
WARNING: Unmatched element: <xsl:value-of select="name()"/>
</xsl:message>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<file>
<xsl:apply-templates />
</file>
</xsl:template>
<xsl:template match="*">
<xsl:message terminate="no">
WARNING: Unmatched element: <xsl:value-of select="name()"/>
</xsl:message>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>