diff --git a/internal/utils/utils.go b/internal/utils/utils.go index c7a2cef..646a9bd 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -183,6 +183,9 @@ func FormatXml(reader io.Reader, writer io.Writer, indent string, colors int) er } hasContent = false lastTagName = currentTagName + if startTagClosed { + lastTagName = "" + } case xml.Directive: _, _ = fmt.Fprint(writer, tagColor("")) _, _ = fmt.Fprint(writer, newline, strings.Repeat(indent, level)) diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index 64e1ba5..a0da201 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -36,6 +36,7 @@ func TestFormatXml(t *testing.T) { "unformatted11.xml": "formatted11.xml", "unformatted12.xml": "formatted12.xml", "unformatted13.xml": "formatted13.xml", + "unformatted14.xml": "formatted14.xml", } for unformattedFile, expectedFile := range files { diff --git a/test/data/xml/formatted14.xml b/test/data/xml/formatted14.xml new file mode 100644 index 0000000..6080fe9 --- /dev/null +++ b/test/data/xml/formatted14.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/test/data/xml/unformatted14.xml b/test/data/xml/unformatted14.xml new file mode 100644 index 0000000..2c33483 --- /dev/null +++ b/test/data/xml/unformatted14.xml @@ -0,0 +1,7 @@ + + + + + + +