Version 0 of dia2plantuml

Updated 2023-07-28 07:41:43 by DDG

NAME

dia2plantuml - convert textual descriptions for various diagram tools to image URL's using the https://www.plantuml.com/ server.

CODE

### file dia2plantuml.tcl
proc dia2plantuml {text {ext svg}} {
    set b64 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
    set pml 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
    set lmapper [list]
    set i 0
    foreach char [split $b64 ""] {
        lappend lmapper $char
        lappend lmapper [string range $pml $i $i]
        incr i
    }
    set b64 [string map $lmapper [binary encode base64 [string range [zlib compress $text] 2 end-4]]]
    set uri https://www.plantuml.com/plantuml/$ext/$b64
    return $uri
}

TODO: plantuml2dia - decoding image to code, see dia2kroki for starting.

EXAMPLES

dia2plantuml

% source dia2plantuml.tcl
% puts [dia2plantuml "class TclExample"]
https://www.plantuml.com/plantuml/svg/Iyv9B2vM24dESQr8p2t8IGK0

Here the image:

.

Discussion

Please discuss here.