Merge pull request #1894 from alixander/pdf-theme

cli: apply theme to pdf exports
This commit is contained in:
Alexander Wang 2024-04-09 09:57:31 -07:00 committed by GitHub
commit d706e0cf9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 18 additions and 4 deletions

View file

@ -10,6 +10,7 @@
#### Bugfixes ⛑️ #### 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 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 `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) - Fixes edge case of bad import syntax crashing using d2 as a library [#1829](https://github.com/terrastruct/d2/pull/1829)

View file

@ -940,6 +940,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
Sketch: opts.Sketch, Sketch: opts.Sketch,
Center: opts.Center, Center: opts.Center,
Scale: scale, Scale: scale,
ThemeID: opts.ThemeID,
}) })
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -765,6 +765,18 @@ i used to read
assert.Testdata(t, ".svg", svg) 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", name: "renamed-board",
skipCI: true, skipCI: true,

Binary file not shown.