Version 2 of dia2kroki

Updated 2022-02-18 13:09:50 by DDG

NAME

dia2kroki - convert textual descriptions for various diagram tools to image URL's using the https://kroki.io/ webservice.

# dia2kroki.tcl
proc dia2kroki {text {dia graphviz} {ext svg}} {
    set b64 [string map {+ - / _ = ""}  [base64url encode [zlib compress $text]]]
    set uri https://kroki.io//$dia/$ext/$b64
}

EXAMPLE

% source dia2kroki.tcl
% puts [dia2kroki "digraph G { A -> B }"]
https://kroki.io//graphviz/svg/eJxLyUwvSizIUHBXqFZwVNC1U3BSqAUAREAFzQ

This URL can be directly embedded into HTML pages or on Markdown code.

Unfortunately as far as I know Tcler's Wiki can't embed external images without an extension like png, svg etc.

So just the link to the image is shown.

https://kroki.io//graphviz/svg/eJxLyUwvSizIUHBXqFZwVNC1U3BSqAUAREAFzQ

To fix this we have to use the inlinehtml syntax:

<<inlinehtml>>
<img src="https://kroki.io//graphviz/svg/eJxLyUwvSizIUHBXqFZwVNC1U3BSqAUAREAFzQ"> </img>.
<<inlinehtml>>

Here the output:

.

DISCUSSION

Please discuss here: