Closed evaneykelen closed 4 years ago
This is not possible. You can, however, configure the converter
to use any external filter you want. For example, the following should work:
convert = Paru::Pandoc.new do
from "textile"
to "html"
filter "./my_internal_filter.rb"
end
Do also note that filters are called in order, so
converter = Paru::Pandoc.new do
from "textile"
to "html
filter "./first_filter.rb"
filter "./second_filter.rb"
filter "./etc_filter.rb"
end
should work as well. It would first run the first filter on the whole document, then the second on the output of the first, and so on.
@htdebeer: thank you for confirming that run-time execution of "external" Ruby files is the only way to invoke filters.
I love the unix-like piping of filter inputs & outputs btw!
Do note that you can run any script / program as a filter via paru, not only those written in Ruby. The pandoc wrapper part of paru is just a very thin shell around the command-line of pandoc, so anything you can do with pandoc on the command-line you can also do in a paru converter.
you can run any script / program as a filter via paru
This is exactly the reason for my initial hesitation since this is potentially a security issue. I like to avoid run time invocations of shell commands as much as possible. However since the filter is under my control, and not permitting user input, it's safe enough.
I'm looking for a way to embed filters "inline", for example:
Is this possible? Or is there another way?