bauglir/Kroki.jl

(Optionally) enable interactivity for SVGs

Closed this issue · 1 comments

SVGs can contain interactivity, e.g. links to other sites, etc. Currently, SVGs are rendered to img tags with base64 encoded values, at least in Documenter.jl, which breaks this interactivity. This causes, for instance, links in Mermaid diagrams to not work. To enable the interactivity, an SVG would have to be either embedded directly into the final HTML, or be included through an object tag. See this blog post for some in-depth discussion on different approaches for embedding SVGs.

Given that there is a trade-off between the different approaches enabling interactivity should be optional (and likely default to the current approach or something similar). It's probably easiest to reuse the existing options functionality of Diagrams for this, but that is specifically intended for options that should be passed on to Kroki. This option is more relevant towards rendering, so a separate set of options/configuration is probably preferred.

This seems unlikely to be something that can be made to work currently. Interactivity requires the securityLevel for Mermaid to be set to loose1. As of Mermaid v8.2 securityLevel is set to strict by default, disabling interactivity2. Although it is possible to pass some configuration options to Mermaid, for security reasons, securityLevel is in the list of options that is ignored3.

Footnotes

  1. https://mermaid.js.org/syntax/flowchart.html#interaction

  2. https://mermaid.js.org/config/usage.html#securitylevel

  3. https://github.com/yuzutech/kroki/blob/900284f0cfda549b2cd940b19eee37e38d1f0732/docs/modules/setup/pages/diagram-options.adoc?plain=1#L131-L139