Skip to content

v0.5.0

Latest
Compare
Choose a tag to compare
@abhinav abhinav released this 04 Nov 06:00
· 34 commits to main since this release
061ebbe

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 and Theme fields.
    If you need these, you can provide them with the CLICompiler instead.
  • CLI and MMDC were flipped.
    The old MMDC interface is now named CLI, and it now accepts a context.
    You can use the new MMDC function to build an instance of it.
  • ClientRenderer, Extender: Rename MermaidJS to MermaidURL.
  • Rename DefaultMMDC to DefaultCLI.
  • Extender: Replace MMDC field with the CLI field.

Added

  • ServerRenderer now supports pluggable Compilers.
  • 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.