Skip to content

Commit

Permalink
d2ast: Fix RawString test with ampersand
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Jul 30, 2023
1 parent 59d62ab commit aa77cec
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions d2ast/d2ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,11 @@ type InterpolationBox struct {
// & is only special if it begins a key.
// - is only special if followed by another - in a key.
// ' " and | are only special if they begin an unquoted key or value.
var UnquotedKeySpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', ':', '.', '-', '<', '>', '*', '&', '(', ')', '@'})
var UnquotedKeySpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', ':', '.', '-', '<', '>', '*', '&', '(', ')', '@', '&'})
var UnquotedValueSpecials = string([]rune{'#', ';', '\n', '\\', '{', '}', '[', ']', '\'', '"', '|', '$', '@'})

// RawString returns s in a AST String node that can format s in the most aesthetically
// pleasing way.
// TODO: Return StringBox
func RawString(s string, inKey bool) String {
if s == "" {
return FlatDoubleQuotedString(s)
Expand All @@ -1099,10 +1098,6 @@ func RawString(s string, inKey bool) String {
if i+1 < len(s) && s[i+1] != '-' {
continue
}
case '&':
if i > 0 {
continue
}
}
if strings.ContainsRune(UnquotedKeySpecials, r) {
if !strings.ContainsRune(s, '"') {
Expand Down

0 comments on commit aa77cec

Please sign in to comment.