fix: update mermaid.go to match NewRenderEngine signature and ensure cancellation

This commit is contained in:
Manuel Rüger
2026-03-30 11:38:43 +02:00
parent ba67fdc54b
commit ea62c3112a
3 changed files with 5 additions and 4 deletions

2
go.mod
View File

@@ -6,7 +6,7 @@ require (
github.com/bmatcuk/doublestar/v4 v4.10.0
github.com/chromedp/cdproto v0.0.0-20260321001828-e3e3800016bc
github.com/chromedp/chromedp v0.15.1
github.com/dreampuf/mermaid.go v0.0.40
github.com/dreampuf/mermaid.go v0.1.0
github.com/kovetskiy/gopencils v0.0.0-20250404051442-0b776066936a
github.com/rs/zerolog v1.35.0
github.com/stefanfritsch/goldmark-admonitions v1.1.1

4
go.sum
View File

@@ -31,8 +31,8 @@ github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yA
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dop251/goja v0.0.0-20240927123429-241b342198c2 h1:Ux9RXuPQmTB4C1MKagNLme0krvq8ulewfor+ORO/QL4=
github.com/dop251/goja v0.0.0-20240927123429-241b342198c2/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
github.com/dreampuf/mermaid.go v0.0.40 h1:7YUvQFaAR/snbkZtl27JbifT/3bGNURBIVfOnPQKuCE=
github.com/dreampuf/mermaid.go v0.0.40/go.mod h1:9jSzOKzV59UX8Gc9EJ5xuiJeldHpTEmKxF2pwu42r2g=
github.com/dreampuf/mermaid.go v0.1.0 h1:GGD2B6Eowkjjz6ATsvY3ldVSJwU7lS5ddeIKYsm1Yas=
github.com/dreampuf/mermaid.go v0.1.0/go.mod h1:9jSzOKzV59UX8Gc9EJ5xuiJeldHpTEmKxF2pwu42r2g=
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=

View File

@@ -20,11 +20,12 @@ func ProcessMermaidLocally(title string, mermaidDiagram []byte, scale float64) (
defer cancel()
log.Debug().Msgf("Setting up Mermaid renderer: %q", title)
renderer, err := mermaid.NewRenderEngine(ctx)
renderer, err := mermaid.NewRenderEngine(ctx, nil)
if err != nil {
return attachment.Attachment{}, err
}
defer renderer.Cancel()
log.Debug().Msgf("Rendering: %q", title)
pngBytes, boxModel, err := renderer.RenderAsScaledPng(string(mermaidDiagram), scale)