Help with adding a filter as an option to Paru::Pandoc.new.configure
#80
-
Hey there, thanks for writing this library. I'm trying to run Paru with a custom filter, but I'm running into trouble. I've read the docs here but didn't find what I was looking for. I saw lots of great examples on writing filters, but I didn't see anything on passing filters to the converter. Maybe I missed it. I've got the following code:
Just a simple markdown-to-pdf converter, with a filter that counts the number of images in the markdown. I know the options passed to When I run this script, I get the following error:
It appears that Paru is expecting the Thanks in advance for any help. EDIT: OK I think I've made progress by extracting the filter into a file and passing a plain string representing the filter's filename:
However, now I'm getting a new error:
The |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! Thanks for your issue. I see you've managed to solve most of it! To get your example working, I had to change your filter to: #!/bin/env ruby
require "paru/filter"
Paru::Filter.run do
with "Image" do |image|
puts "found image!"
end
end That first line makes it an "executable script" on my operating system. But that differs from system to system. More importantly, you wrote |
Beta Was this translation helpful? Give feedback.
Hi! Thanks for your issue. I see you've managed to solve most of it! To get your example working, I had to change your filter to:
That first line makes it an "executable script" on my operating system. But that differs from system to system.
More importantly, you wrote
Paru::Filter.new
, but that should have beenParu::Filter.run
.#run
is a convenience method to create a filter, connect it to standard input and standard output, and then define and run a filter.