Skip to content

Commit

Permalink
Merge PR #117
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengchun committed Nov 1, 2024
2 parents deda77b + 17a78ac commit bb12302
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,3 +658,13 @@ func TestDirectiveNode(t *testing.T) {
t.Errorf(`expected "%s", obtained "%s"`, expected, v)
}
}

func TestOutputXMLWithSingleQuotes(t *testing.T) {
s := `<?xml version='1.0' encoding='utf-8'?><a><b c='d'></b></a>`
expected := `<?xml version="1.0" encoding="utf-8"?><a><b c="d"></b></a>`
doc, _ := Parse(strings.NewReader(s))
output := doc.OutputXML(false)
if expected != output {
t.Errorf(`expected "%s", obtained "%s"`, expected, output)
}
}
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (p *parser) parse() (*Node, error) {
for _, pair := range pairs {
pair = strings.TrimSpace(pair)
if i := strings.Index(pair, "="); i > 0 {
AddAttr(node, pair[:i], strings.Trim(pair[i+1:], `"`))
AddAttr(node, pair[:i], strings.Trim(pair[i+1:], `"'`))
}
}
if p.level == p.prev.level {
Expand Down

0 comments on commit bb12302

Please sign in to comment.