cli: apply theme to pdf exports

This commit is contained in:
Alexander Wang 2024-04-09 09:51:14 -07:00
parent 19d5d38981
commit 6ea88eaad2
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
8 changed files with 18 additions and 4 deletions

View file

@ -10,6 +10,7 @@
#### Bugfixes ⛑️
- Theme flags on CLI apply to PDFs [#1894](https://github.com/terrastruct/d2/pull/1894)
- Fixes styles in connections not overriding styles set by globs [#1857](https://github.com/terrastruct/d2/pull/1857)
- Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [#1830](https://github.com/terrastruct/d2/pull/1830)
- Fixes edge case of bad import syntax crashing using d2 as a library [#1829](https://github.com/terrastruct/d2/pull/1829)

View file

@ -936,10 +936,11 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
}
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,
})
if err != nil {
return nil, err

View file

@ -765,6 +765,18 @@ i used to read
assert.Testdata(t, ".svg", svg)
},
},
{
name: "theme-pdf",
skipCI: true,
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
writeFile(t, dir, "in.d2", `x -> y`)
err := runTestMain(t, ctx, dir, env, "--theme=5", "in.d2", "out.pdf")
assert.Success(t, err)
pdf := readFile(t, dir, "out.pdf")
testdataIgnoreDiff(t, ".pdf", pdf)
},
},
{
name: "renamed-board",
skipCI: true,

Binary file not shown.