Skip to content

Commit

Permalink
Fix #37: Handle special XML namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Jul 27, 2023
1 parent 2234907 commit 66e5539
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func FormatXml(reader io.Reader, writer io.Writer, indent string, colors int) er

level := 0
hasContent := false
nsAliases := map[string]string{}
nsAliases := map[string]string{"http://www.w3.org/XML/1998/namespace": "xml"}
lastTagName := ""
startTagClosed := true

Expand Down
1 change: 1 addition & 0 deletions internal/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestFormatXml(t *testing.T) {
"unformatted9.xml": "formatted9.xml",
"unformatted10.xml": "formatted10.xml",
"unformatted11.xml": "formatted11.xml",
"unformatted12.xml": "formatted12.xml",
}

for unformattedFile, expectedFile := range files {
Expand Down
3 changes: 3 additions & 0 deletions test/data/xml/formatted12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<document>
<element xml:lang="en">value</element>
</document>
3 changes: 3 additions & 0 deletions test/data/xml/unformatted12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<document>
<element xml:lang="en">value</element>
</document>

0 comments on commit 66e5539

Please sign in to comment.