I am sorry to ask such a question. But I am really new to Haskell. I searched the Internet for a whole day but didn't find any example.
I have a pandoc filter written in python (tikzcd.py
). I want to use that filter to process my blog posts.
I guess I need to use unixFilter
or pandocCompileWithTransform
but my knowledge to Haskell is really not enough to find a solution myself.
So, could someone provide me an example?
-----------U--P--D--A--T--E--S---------------
@Michael gives an solution using pandocCompileWithTransformM
and unixFilter
. It works. But there is a problem.
When using a filter from command line, what I will do is
pandoc -t json -READEROPTIONS input.markdown | ./filter.py | pandoc -f JSON -WRITEROPTIONS -o output.html
or equivalentlypandoc --filter ./filter.py -READEROPTIONS -WRITEROPTIONS -o html
This command is shorter but it doesn't show the procedures.
But with pandocCompilerTransformM
, it does something like
pandoc -t html -READEROPTIONS -WRITEROPTIONS input.mardown | pandoc -t JSON | ./filter.py | pandoc -f JSON -WRITEROPTIONS -o output.html
The difference is that the text that passed to filter.py
is different: one is the contents directly produced from markdown, while the other is some texts produced from HTML that was produced from markdown. As you know, to convert something back and forth will always produce unexpected problem. So I think there may be a better solution.
PS. I've stared to learn Haskell. I hope I could solve this problem myself someday. Thank you!