**NAME** dia2kroki - convert textual descriptions for various diagram tools to image URL's using the https://kroki.io/ webservice. <> **CODE** ====== # 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 } # like to know the code of an URL proc kroki2dia {url} { set text [regsub {.+/} $url ""] set dia [zlib decompress [binary decode base64 [string map {- + _ /} $text]]] } ====== **EXAMPLES** ***dia2kroki*** ====== % 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: ====== <> . <> ====== 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: <> <> ***kroki2dia*** Using `kroki2dia` you can get the code of an kroki URL back to text: ====== % kroki2dia https://kroki.io//graphviz/svg/eJxLyUwvSizIUHBXqFZwVNC1U3BSqAUAREAFzQ digraph G { A -> B } ====== ---- **DISCUSSION** Please discuss here. [DDG] - 2022-02-18: The main advantage of this little function is that you can create these images without having all these diagram tools installed just using basic Tcl (8.6). You can embed the images directly into your documentation using a simple hyperlink or you can download the images using Tcl with the [http] and [tls] libraries or a tool like wget.