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 💸
|
#### Features 💸
|
||||||
|
|
||||||
|
- Ability to export to PNG
|
||||||
- Now you can easily do x, y and z #9999
|
- Now you can easily do x, y and z #9999
|
||||||
- Ability to export to PNGs
|
|
||||||
|
|
||||||
#### Improvements 🔧
|
#### Improvements 🔧
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,12 +133,11 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() error {
|
defer func() {
|
||||||
err = pw.Cleanup()
|
cleanupErr := pw.Cleanup()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return err
|
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)
|
encodedSVG := base64.StdEncoding.EncodeToString(svg)
|
||||||
pngInterface, err := page.Evaluate(genPNGScript, "data:image/svg+xml;charset=utf-8;base64,"+encodedSVG)
|
pngInterface, err := page.Evaluate(genPNGScript, "data:image/svg+xml;charset=utf-8;base64,"+encodedSVG)
|
||||||
if err != nil {
|
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)
|
pngString := pngInterface.(string)
|
||||||
|
|
@ -85,7 +85,7 @@ func ConvertSVG(ms *xmain.State, page playwright.Page, svg []byte) ([]byte, erro
|
||||||
if len(pngString) > 50 {
|
if len(pngString) > 50 {
|
||||||
pngString = pngString[0: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):]
|
splicedPNGString := pngString[len(pngPrefix):]
|
||||||
return base64.StdEncoding.DecodeString(splicedPNGString)
|
return base64.StdEncoding.DecodeString(splicedPNGString)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue