@@ -529,7 +529,7 @@ func compile(ctx context.Context, ms *xmain.State, plugins []d2plugin.Plugin, fs
529
529
ext := getExportExtension (outputPath )
530
530
switch ext {
531
531
case GIF :
532
- svg , pngs , err := renderPNGsForGIF (ctx , ms , plugin , renderOpts , ruler , page , diagram )
532
+ svg , pngs , err := renderPNGsForGIF (ctx , ms , plugin , renderOpts , ruler , page , inputPath , diagram )
533
533
if err != nil {
534
534
return nil , false , err
535
535
}
@@ -553,7 +553,7 @@ func compile(ctx context.Context, ms *xmain.State, plugins []d2plugin.Plugin, fs
553
553
path := []pdf.BoardTitle {
554
554
{Name : diagram .Root .Label , BoardID : "root" },
555
555
}
556
- pdf , err := renderPDF (ctx , ms , plugin , renderOpts , outputPath , page , ruler , diagram , nil , path , pageMap , diagram .Root .Label != "" )
556
+ pdf , err := renderPDF (ctx , ms , plugin , renderOpts , inputPath , outputPath , page , ruler , diagram , nil , path , pageMap , diagram .Root .Label != "" )
557
557
if err != nil {
558
558
return pdf , false , err
559
559
}
@@ -574,7 +574,7 @@ func compile(ctx context.Context, ms *xmain.State, plugins []d2plugin.Plugin, fs
574
574
path := []pptx.BoardTitle {
575
575
{Name : "root" , BoardID : "root" , LinkToSlide : boardIdToIndex ["root" ] + 1 },
576
576
}
577
- svg , err := renderPPTX (ctx , ms , p , plugin , renderOpts , ruler , outputPath , page , diagram , path , boardIdToIndex )
577
+ svg , err := renderPPTX (ctx , ms , p , plugin , renderOpts , ruler , inputPath , outputPath , page , diagram , path , boardIdToIndex )
578
578
if err != nil {
579
579
return nil , false , err
580
580
}
@@ -808,7 +808,7 @@ func render(ctx context.Context, ms *xmain.State, compileDur time.Duration, plug
808
808
809
809
if ! diagram .IsFolderOnly {
810
810
start := time .Now ()
811
- out , err := _render (ctx , ms , plugin , opts , boardOutputPath , bundle , forceAppendix , page , ruler , diagram )
811
+ out , err := _render (ctx , ms , plugin , opts , inputPath , boardOutputPath , bundle , forceAppendix , page , ruler , diagram )
812
812
if err != nil {
813
813
return boards , err
814
814
}
@@ -824,7 +824,7 @@ func render(ctx context.Context, ms *xmain.State, compileDur time.Duration, plug
824
824
825
825
func renderSingle (ctx context.Context , ms * xmain.State , compileDur time.Duration , plugin d2plugin.Plugin , opts d2svg.RenderOpts , inputPath , outputPath string , bundle , forceAppendix bool , page playwright.Page , ruler * textmeasure.Ruler , diagram * d2target.Diagram ) ([][]byte , error ) {
826
826
start := time .Now ()
827
- out , err := _render (ctx , ms , plugin , opts , outputPath , bundle , forceAppendix , page , ruler , diagram )
827
+ out , err := _render (ctx , ms , plugin , opts , inputPath , outputPath , bundle , forceAppendix , page , ruler , diagram )
828
828
if err != nil {
829
829
return [][]byte {}, err
830
830
}
@@ -835,7 +835,7 @@ func renderSingle(ctx context.Context, ms *xmain.State, compileDur time.Duration
835
835
return [][]byte {out }, nil
836
836
}
837
837
838
- func _render (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , outputPath string , bundle , forceAppendix bool , page playwright.Page , ruler * textmeasure.Ruler , diagram * d2target.Diagram ) ([]byte , error ) {
838
+ func _render (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , inputPath , outputPath string , bundle , forceAppendix bool , page playwright.Page , ruler * textmeasure.Ruler , diagram * d2target.Diagram ) ([]byte , error ) {
839
839
toPNG := getExportExtension (outputPath ) == PNG
840
840
var scale * float64
841
841
if opts .Scale != nil {
@@ -865,7 +865,7 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opts
865
865
866
866
cacheImages := ms .Env .Getenv ("IMG_CACHE" ) == "1"
867
867
l := simplelog .FromCmdLog (ms .Log )
868
- svg , bundleErr := imgbundler .BundleLocal (ctx , l , svg , cacheImages )
868
+ svg , bundleErr := imgbundler .BundleLocal (ctx , l , inputPath , svg , cacheImages )
869
869
if bundle {
870
870
var bundleErr2 error
871
871
svg , bundleErr2 = imgbundler .BundleRemote (ctx , l , svg , cacheImages )
@@ -915,7 +915,7 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opts
915
915
return svg , nil
916
916
}
917
917
918
- func renderPDF (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , outputPath string , page playwright.Page , ruler * textmeasure.Ruler , diagram * d2target.Diagram , doc * pdf.GoFPDF , boardPath []pdf.BoardTitle , pageMap map [string ]int , includeNav bool ) (svg []byte , err error ) {
918
+ func renderPDF (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , inputPath , outputPath string , page playwright.Page , ruler * textmeasure.Ruler , diagram * d2target.Diagram , doc * pdf.GoFPDF , boardPath []pdf.BoardTitle , pageMap map [string ]int , includeNav bool ) (svg []byte , err error ) {
919
919
var isRoot bool
920
920
if doc == nil {
921
921
doc = pdf .Init ()
@@ -953,7 +953,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
953
953
954
954
cacheImages := ms .Env .Getenv ("IMG_CACHE" ) == "1"
955
955
l := simplelog .FromCmdLog (ms .Log )
956
- svg , bundleErr := imgbundler .BundleLocal (ctx , l , svg , cacheImages )
956
+ svg , bundleErr := imgbundler .BundleLocal (ctx , l , inputPath , svg , cacheImages )
957
957
svg , bundleErr2 := imgbundler .BundleRemote (ctx , l , svg , cacheImages )
958
958
bundleErr = multierr .Combine (bundleErr , bundleErr2 )
959
959
if bundleErr != nil {
@@ -986,7 +986,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
986
986
Name : dl .Root .Label ,
987
987
BoardID : strings .Join ([]string {boardPath [len (boardPath )- 1 ].BoardID , LAYERS , dl .Name }, "." ),
988
988
})
989
- _ , err := renderPDF (ctx , ms , plugin , opts , "" , page , ruler , dl , doc , path , pageMap , includeNav )
989
+ _ , err := renderPDF (ctx , ms , plugin , opts , inputPath , "" , page , ruler , dl , doc , path , pageMap , includeNav )
990
990
if err != nil {
991
991
return nil , err
992
992
}
@@ -996,7 +996,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
996
996
Name : dl .Root .Label ,
997
997
BoardID : strings .Join ([]string {boardPath [len (boardPath )- 1 ].BoardID , SCENARIOS , dl .Name }, "." ),
998
998
})
999
- _ , err := renderPDF (ctx , ms , plugin , opts , "" , page , ruler , dl , doc , path , pageMap , includeNav )
999
+ _ , err := renderPDF (ctx , ms , plugin , opts , inputPath , "" , page , ruler , dl , doc , path , pageMap , includeNav )
1000
1000
if err != nil {
1001
1001
return nil , err
1002
1002
}
@@ -1006,7 +1006,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
1006
1006
Name : dl .Root .Label ,
1007
1007
BoardID : strings .Join ([]string {boardPath [len (boardPath )- 1 ].BoardID , STEPS , dl .Name }, "." ),
1008
1008
})
1009
- _ , err := renderPDF (ctx , ms , plugin , opts , "" , page , ruler , dl , doc , path , pageMap , includeNav )
1009
+ _ , err := renderPDF (ctx , ms , plugin , opts , inputPath , "" , page , ruler , dl , doc , path , pageMap , includeNav )
1010
1010
if err != nil {
1011
1011
return nil , err
1012
1012
}
@@ -1022,7 +1022,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
1022
1022
return svg , nil
1023
1023
}
1024
1024
1025
- func renderPPTX (ctx context.Context , ms * xmain.State , presentation * pptx.Presentation , plugin d2plugin.Plugin , opts d2svg.RenderOpts , ruler * textmeasure.Ruler , outputPath string , page playwright.Page , diagram * d2target.Diagram , boardPath []pptx.BoardTitle , boardIDToIndex map [string ]int ) ([]byte , error ) {
1025
+ func renderPPTX (ctx context.Context , ms * xmain.State , presentation * pptx.Presentation , plugin d2plugin.Plugin , opts d2svg.RenderOpts , ruler * textmeasure.Ruler , inputPath , outputPath string , page playwright.Page , diagram * d2target.Diagram , boardPath []pptx.BoardTitle , boardIDToIndex map [string ]int ) ([]byte , error ) {
1026
1026
var svg []byte
1027
1027
if ! diagram .IsFolderOnly {
1028
1028
// gofpdf will print the png img with a slight filter
@@ -1055,7 +1055,7 @@ func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Present
1055
1055
1056
1056
cacheImages := ms .Env .Getenv ("IMG_CACHE" ) == "1"
1057
1057
l := simplelog .FromCmdLog (ms .Log )
1058
- svg , bundleErr := imgbundler .BundleLocal (ctx , l , svg , cacheImages )
1058
+ svg , bundleErr := imgbundler .BundleLocal (ctx , l , inputPath , svg , cacheImages )
1059
1059
svg , bundleErr2 := imgbundler .BundleRemote (ctx , l , svg , cacheImages )
1060
1060
bundleErr = multierr .Combine (bundleErr , bundleErr2 )
1061
1061
if bundleErr != nil {
@@ -1120,7 +1120,7 @@ func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Present
1120
1120
BoardID : boardID ,
1121
1121
LinkToSlide : boardIDToIndex [boardID ] + 1 ,
1122
1122
})
1123
- _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , "" , page , dl , path , boardIDToIndex )
1123
+ _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , inputPath , "" , page , dl , path , boardIDToIndex )
1124
1124
if err != nil {
1125
1125
return nil , err
1126
1126
}
@@ -1132,7 +1132,7 @@ func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Present
1132
1132
BoardID : boardID ,
1133
1133
LinkToSlide : boardIDToIndex [boardID ] + 1 ,
1134
1134
})
1135
- _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , "" , page , dl , path , boardIDToIndex )
1135
+ _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , inputPath , "" , page , dl , path , boardIDToIndex )
1136
1136
if err != nil {
1137
1137
return nil , err
1138
1138
}
@@ -1144,7 +1144,7 @@ func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Present
1144
1144
BoardID : boardID ,
1145
1145
LinkToSlide : boardIDToIndex [boardID ] + 1 ,
1146
1146
})
1147
- _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , "" , page , dl , path , boardIDToIndex )
1147
+ _ , err := renderPPTX (ctx , ms , presentation , plugin , opts , ruler , inputPath , "" , page , dl , path , boardIDToIndex )
1148
1148
if err != nil {
1149
1149
return nil , err
1150
1150
}
@@ -1276,7 +1276,7 @@ func buildBoardIDToIndex(diagram *d2target.Diagram, dictionary map[string]int, p
1276
1276
return dictionary
1277
1277
}
1278
1278
1279
- func renderPNGsForGIF (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , ruler * textmeasure.Ruler , page playwright.Page , diagram * d2target.Diagram ) (svg []byte , pngs [][]byte , err error ) {
1279
+ func renderPNGsForGIF (ctx context.Context , ms * xmain.State , plugin d2plugin.Plugin , opts d2svg.RenderOpts , ruler * textmeasure.Ruler , page playwright.Page , inputPath string , diagram * d2target.Diagram ) (svg []byte , pngs [][]byte , err error ) {
1280
1280
if ! diagram .IsFolderOnly {
1281
1281
1282
1282
var scale * float64
@@ -1302,7 +1302,7 @@ func renderPNGsForGIF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plug
1302
1302
1303
1303
cacheImages := ms .Env .Getenv ("IMG_CACHE" ) == "1"
1304
1304
l := simplelog .FromCmdLog (ms .Log )
1305
- svg , bundleErr := imgbundler .BundleLocal (ctx , l , svg , cacheImages )
1305
+ svg , bundleErr := imgbundler .BundleLocal (ctx , l , inputPath , svg , cacheImages )
1306
1306
svg , bundleErr2 := imgbundler .BundleRemote (ctx , l , svg , cacheImages )
1307
1307
bundleErr = multierr .Combine (bundleErr , bundleErr2 )
1308
1308
if bundleErr != nil {
@@ -1319,21 +1319,21 @@ func renderPNGsForGIF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plug
1319
1319
}
1320
1320
1321
1321
for _ , dl := range diagram .Layers {
1322
- _ , layerPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , dl )
1322
+ _ , layerPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , inputPath , dl )
1323
1323
if err != nil {
1324
1324
return nil , nil , err
1325
1325
}
1326
1326
pngs = append (pngs , layerPNGs ... )
1327
1327
}
1328
1328
for _ , dl := range diagram .Scenarios {
1329
- _ , scenarioPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , dl )
1329
+ _ , scenarioPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , inputPath , dl )
1330
1330
if err != nil {
1331
1331
return nil , nil , err
1332
1332
}
1333
1333
pngs = append (pngs , scenarioPNGs ... )
1334
1334
}
1335
1335
for _ , dl := range diagram .Steps {
1336
- _ , stepsPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , dl )
1336
+ _ , stepsPNGs , err := renderPNGsForGIF (ctx , ms , plugin , opts , ruler , page , inputPath , dl )
1337
1337
if err != nil {
1338
1338
return nil , nil , err
1339
1339
}
0 commit comments