Skip to content

Commit

Permalink
Merge pull request #2099 from alixander/theme-overrides
Browse files Browse the repository at this point in the history
d2cli: fix pptx using theme flags
  • Loading branch information
alixander authored Sep 16, 2024
2 parents 25e67cb + c6ac177 commit d5734fb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
- CLI: fixes edge case of watch mode links to nested board that had more nested boards not working [#2070](https://github.com/terrastruct/d2/pull/2070)
- CLI: fixes theme flag not being passed to GIF outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
- CLI: fixes scale flag not being passed to animated SVG outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
- CLI: pptx exports use theme flags correctly [#2099](https://github.com/terrastruct/d2/pull/2099)
12 changes: 8 additions & 4 deletions d2cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,10 +1048,14 @@ func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Present
var err error

svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
Pad: opts.Pad,
Sketch: opts.Sketch,
Center: opts.Center,
Scale: scale,
Pad: opts.Pad,
Sketch: opts.Sketch,
Center: opts.Center,
Scale: scale,
ThemeID: opts.ThemeID,
DarkThemeID: opts.DarkThemeID,
ThemeOverrides: opts.ThemeOverrides,
DarkThemeOverrides: opts.DarkThemeOverrides,
})
if err != nil {
return nil, err
Expand Down
37 changes: 37 additions & 0 deletions e2etests-cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,43 @@ steps: {
assert.Success(t, err)
},
},
{
name: "pptx-theme-overrides",
skipCI: true,
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
writeFile(t, dir, "in.d2", `vars:{
d2-config: {
theme-overrides: {
# All red
N1: "#ff0000"
B1: "#ff0000"
B2: "#ff0000"
AA2: "#ff0000"
N2: "#ff0000"
N6: "#ff0000"
B4: "#ff0000"
B5: "#ff0000"
B3: "#ff0000"
N4: "#ff0000"
N5: "#ff0000"
AA4: "#ff0000"
AB4: "#ff0000"
B6: "#ff0000"
N7: "#ff0000"
AA5: "#ff0000"
AB5: "#ff0000"
}
}
}
a->z
a.b.c.d
`)
err := runTestMain(t, ctx, dir, env, "in.d2", "all_red.pptx")
assert.Success(t, err)
pptx := readFile(t, dir, "all_red.pptx")
testdataIgnoreDiff(t, ".pptx", pptx)
},
},
{
name: "one-layer-gif",
skipCI: true,
Expand Down
Binary file not shown.

0 comments on commit d5734fb

Please sign in to comment.