Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite as pandoc filter? #6

Open
bpj opened this issue Apr 4, 2016 · 5 comments
Open

Rewrite as pandoc filter? #6

bpj opened this issue Apr 4, 2016 · 5 comments

Comments

@bpj
Copy link

bpj commented Apr 4, 2016

@nichtich, would you mind me taking a stab at rewriting this as a pandoc filter?

/bpj

@nichtich
Copy link
Owner

nichtich commented Apr 4, 2016

Please do so! See also nichtich/Pandoc-Elements#12 for ideas of improvement (parallel processing).

@bpj
Copy link
Author

bpj commented Apr 4, 2016

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!

@nichtich
Copy link
Owner

nichtich commented Apr 4, 2016

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

  1. transform the full AST and collect a list of system calls
  2. execute instances of external commands (ditaa...) in parallel
  3. 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.

@bpj
Copy link
Author

bpj commented Apr 4, 2016

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.

@nichtich
Copy link
Owner

nichtich commented Apr 6, 2016

Thanks, this should be included as another example filter in Pandoc::Elements! See my comments at https://gist.github.com/bpj/5454765371a4e3c1a8354fedced1cc6b#gistcomment-1743401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants