In Jekyll, the above ditaa tag will trigger a plugin that will execute a command line executable with optional args, save the generate svg to a file and link the image file to the post. The jekyll build will also copy the generated svg file to the _site output folder.
The above example is specific to the ditaa plugin, but it seems that there could be a single exec tag to rule them all.
In Hugo we have the Highlight shortcode that triggers pygments (code highlighting), but nothing like “trigger any external program”. I guess that’s doable, and might even be a good idea.
I implemented this locally – and altough very cool, there is this security aspect of it, allowing execution of “all kinds of” commands on a user’s PC (from a shortcode in a theme …).