Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- fixes inconsistencies when objects were double quoted [#2390](https://github.com/terrastruct/d2/pull/2390)
- fixes globs not applying to spread substitutions [#2426](https://github.com/terrastruct/d2/issues/2426)
- fixes panic when classes were mixed with layers incorrectly [#2448](https://github.com/terrastruct/d2/pull/2448)
- Formatter:
- fixes substitutions in quotes surrounded by text [#2462](https://github.com/terrastruct/d2/pull/2462)
- CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370)
- Composition: spread importing scenarios/steps was not inheriting correctly [#2460](https://github.com/terrastruct/d2/pull/2460)
- Markdown: fixes nested var substitutions not working [#2456](https://github.com/terrastruct/d2/pull/2456)
Expand Down
7 changes: 6 additions & 1 deletion d2format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions d2format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
}
`,
},
}
Expand Down