Version 4 of dia2kroki

Updated 2022-02-18 13:58:20 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 {+ - / _ = ""}  [binary encode base64 [zlib compress $text]]]
    set uri https://kroki.io//$dia/$ext/$b64
}

EXAMPLES

% 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:

.

Here an example for plantuml: http://www.plantuml.com

% source dia2kroki.tcl
% dia2kroki {
@startuml
Bob -> Alice : hello
@enduml
} plantuml png
https://kroki.io//plantuml/png/eJzjciguSSwqKc3N4XLKT1LQtVNwzMlMTlWwUshIzcnJ53JIzUsBSQIABnMM1A

Here this image, this time a PNG:


DISCUSSION

Please discuss here: