fix watch mode for pdf gen
This commit is contained in:
parent
890a7d8b2c
commit
31fdaad555
2 changed files with 3 additions and 5 deletions
6
main.go
6
main.go
|
|
@ -356,7 +356,7 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc
|
|||
return svg, nil
|
||||
}
|
||||
|
||||
func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketch bool, pad int64, outputPath string, page playwright.Page, ruler *textmeasure.Ruler, diagram *d2target.Diagram, pdf *pdflib.GoFPDF, boardPath []string, isScenario bool) ([]byte, error) {
|
||||
func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketch bool, pad int64, outputPath string, page playwright.Page, ruler *textmeasure.Ruler, diagram *d2target.Diagram, pdf *pdflib.GoFPDF, boardPath []string, isScenario bool) (svg []byte, err error) {
|
||||
var isRoot bool
|
||||
if pdf == nil {
|
||||
pdf = pdflib.Init()
|
||||
|
|
@ -375,9 +375,8 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, ske
|
|||
currBoardPath = append(boardPath, diagram.Name)
|
||||
}
|
||||
|
||||
var svg []byte
|
||||
if !isScenario {
|
||||
svg, err := d2svg.Render(diagram, &d2svg.RenderOpts{
|
||||
svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
|
||||
Pad: int(pad),
|
||||
Sketch: sketch,
|
||||
})
|
||||
|
|
@ -407,7 +406,6 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, ske
|
|||
if err != nil {
|
||||
return svg, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for _, dl := range diagram.Layers {
|
||||
|
|
|
|||
2
watch.go
2
watch.go
|
|
@ -344,7 +344,7 @@ func (w *watcher) compileLoop(ctx context.Context) error {
|
|||
recompiledPrefix = "re"
|
||||
}
|
||||
|
||||
if filepath.Ext(w.outputPath) == ".png" && !w.pw.Browser.IsConnected() {
|
||||
if (filepath.Ext(w.outputPath) == ".png" || filepath.Ext(w.outputPath) == ".pdf") && !w.pw.Browser.IsConnected() {
|
||||
newPW, err := w.pw.RestartBrowser()
|
||||
if err != nil {
|
||||
broadcastErr := fmt.Errorf("issue encountered with PNG exporter: %w", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue