v0.5.0 - 2023-11-03
This release brings support for rendering diagrams server-side
without the need for the MermaidJS CLI.
You can use this functionality by installing a mermaidcdp.Compiler
into your mermaid.Extender
or mermaid.ServerRenderer
.
For example:
import "go.abhg.dev/goldmark/mermaid/mermaidcdp"
compiler, err := mermaidcdp.New(&mermaidcdp.Config{
JSSource: mermaidJSSource, // contents of mermaid.min.js
})
if err != nil {
return err
}
defer compiler.Close()
md := goldmark.New(
goldmark.WithExtensions(
// ...
&mermaid.Extender{
Compiler: compiler,
},
),
// ...
)
Use of mermaidcdp is highly recommended for server-side rendering
if you have lots of diagrams or documents to render.
This should be substantially faster than invoking the mmdc
CLI.
Breaking changes
- ServerRenderer: Delete
MMDC
andTheme
fields.
If you need these, you can provide them with theCLICompiler
instead. CLI
andMMDC
were flipped.
The oldMMDC
interface is now namedCLI
, and it now accepts a context.
You can use the newMMDC
function to build an instance of it.- ClientRenderer, Extender: Rename
MermaidJS
toMermaidURL
. - Rename
DefaultMMDC
toDefaultCLI
. - Extender: Replace
MMDC
field with theCLI
field.
Added
- ServerRenderer now supports pluggable
Compiler
s. - Add
CLICompiler
to render diagrams by invoking MermaidJS CLI. Plugs into ServerRenderer. - Add mermaidcdp subpackage to render diagrams with a long-running Chromium-based process.
Plugs into ServerRenderer.