ditaa-markdown
ditaa-markdown copied to clipboard
Rewrite as pandoc filter?
@nichtich, would you mind me taking a stab at rewriting this as a pandoc filter?
/bpj
Please do so! See also https://github.com/nichtich/Pandoc-Elements/issues/12 for ideas of improvement (parallel processing).
App::pandoc::preprocess is way to hairy for my taste. In fact I prefer https://metacpan.org/pod/IPC::Run3 to using system
directly, having been bitten by too much weirdness in the past.
The main advantage of a filter as I see it is that you get a whole code block as a string, write it to a file directly or indirectly, convert and are done. If you moreover do it without any nasty surprises from the shell the happier am I!
App::pandoc::preprocess can be replaced by filters as well. But there should be a way parallelize execution of external commands such as ditaa. Executed via
pandoc --filter filter.pl < in > out
The script filter.pl
would
- transform the full AST and collect a list of system calls
- execute instances of external commands (ditaa...) in parallel
- emit the transformed AST after last execution has ended
This is almost what App::pandoc::preprocess does. Sure we can first have an "easy" solution that directly executes the system calls instead of parallizing them.
The script filter.pl would
transform the full AST and collect a list of system calls execute instances of external commands (ditaa...) in parallel emit the transformed AST after last execution has ended
This is almost what App::pandoc::preprocess does. Sure we can first have an "easy" solution that directly executes the system calls instead of parallizing them.
Yes, I see that now. The code is so hairy I have problems following it.
Anyway you can see what I have done here. You will have to install File::Slurper.
BTW there was a test error when installing rdfdot.
Thanks, this should be included as another example filter in Pandoc::Elements! See my comments at https://gist.github.com/bpj/5454765371a4e3c1a8354fedced1cc6b#gistcomment-1743401