PR comments
This commit is contained in:
parent
ab40e9a900
commit
b99b741651
4 changed files with 8 additions and 9 deletions
|
|
@ -2,8 +2,8 @@ For v0.0.99 we focused on X, Y and Z. Enjoy!
|
|||
|
||||
#### Features 💸
|
||||
|
||||
- Ability to export to PNG
|
||||
- Now you can easily do x, y and z #9999
|
||||
- Ability to export to PNGs
|
||||
|
||||
#### Improvements 🔧
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
.Nm
|
||||
compiles and renders
|
||||
.Ar file.d2
|
||||
to
|
||||
to
|
||||
.Ar file.svg
|
||||
|
|
||||
.Ar file.png
|
||||
|
|
|
|||
|
|
@ -133,12 +133,11 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() error {
|
||||
err = pw.Cleanup()
|
||||
if err != nil {
|
||||
return err
|
||||
defer func() {
|
||||
cleanupErr := pw.Cleanup()
|
||||
if err == nil {
|
||||
err = cleanupErr
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func ConvertSVG(ms *xmain.State, page playwright.Page, svg []byte) ([]byte, erro
|
|||
encodedSVG := base64.StdEncoding.EncodeToString(svg)
|
||||
pngInterface, err := page.Evaluate(genPNGScript, "data:image/svg+xml;charset=utf-8;base64,"+encodedSVG)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate png: %w\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", err)
|
||||
return nil, fmt.Errorf("failed to generate png: %w", err)
|
||||
}
|
||||
|
||||
pngString := pngInterface.(string)
|
||||
|
|
@ -85,7 +85,7 @@ func ConvertSVG(ms *xmain.State, page playwright.Page, svg []byte) ([]byte, erro
|
|||
if len(pngString) > 50 {
|
||||
pngString = pngString[0:50] + "..."
|
||||
}
|
||||
return nil, fmt.Errorf("invalid PNG: %q\nplease report this issue here: https://github.com/terrastruct/d2/issues/new", pngString)
|
||||
return nil, fmt.Errorf("invalid PNG: %q", pngString)
|
||||
}
|
||||
splicedPNGString := pngString[len(pngPrefix):]
|
||||
return base64.StdEncoding.DecodeString(splicedPNGString)
|
||||
|
|
|
|||
Loading…
Reference in a new issue