fix vars fmt
This commit is contained in:
parent
a712d91be5
commit
f2b9bba0df
2 changed files with 19 additions and 1 deletions
|
|
@ -127,7 +127,7 @@ func (p *printer) blockComment(bc *d2ast.BlockComment) {
|
|||
}
|
||||
|
||||
func (p *printer) interpolationBoxes(boxes []d2ast.InterpolationBox, isDoubleString bool) {
|
||||
for _, b := range boxes {
|
||||
for i, b := range boxes {
|
||||
if b.Substitution != nil {
|
||||
p.substitution(b.Substitution)
|
||||
continue
|
||||
|
|
@ -140,6 +140,11 @@ func (p *printer) interpolationBoxes(boxes []d2ast.InterpolationBox, isDoubleStr
|
|||
s = escapeUnquotedValue(*b.String, p.inKey)
|
||||
}
|
||||
b.StringRaw = &s
|
||||
} else if i > 0 && boxes[i-1].Substitution != nil {
|
||||
// If this string follows a substitution, we need to make sure to use
|
||||
// the actual string content, not the raw value which might be incorrect
|
||||
s := *b.String
|
||||
b.StringRaw = &s
|
||||
}
|
||||
if !isDoubleString {
|
||||
if _, ok := d2ast.ReservedKeywords[strings.ToLower(*b.StringRaw)]; ok {
|
||||
|
|
|
|||
|
|
@ -892,6 +892,19 @@ scenarios: {}
|
|||
steps: asdf
|
||||
`,
|
||||
exp: `k
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "vars",
|
||||
in: `vars: {
|
||||
a: "a"
|
||||
b: "X${a})"
|
||||
}
|
||||
`,
|
||||
exp: `vars: {
|
||||
a: "a"
|
||||
b: "X${a})"
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue