I am trying to use a canned example from Pandoc's scripting page, but I don't understand enough Haskell to make this work. Here's the script.

#!/usr/bin/env runhaskell
-- includes.hs
import Text.Pandoc.JSON

doInclude :: Block -> IO Block
doInclude cb@(CodeBlock (id, classes, namevals) contents) =
  case lookup "include" namevals of
       Just f     -> return . (CodeBlock (id, classes, namevals)) =<< readFile f
       Nothing    -> return cb
doInclude x = return x

main :: IO ()
main = toJSONFilter doInclude

I saved this as includes.hs. To use it as a Panodc filter I need to compile it, so I ran ghc --make include.hs, but got the following error.

C:\Users\richa_000\Dropbox\CV>ghc --make includes.hs

    Could not find module `Text.Pandoc.JSON'
    Use -v to see a list of the files searched for.

Isn't Text.PANDOC.JSON installed with Pandoc? I can't find any information on how to install package. Am I going about this the wrong way? Thanks!


I found the answer in this related SO question. I need to add the Pandoc libraries to Haskell.

Here's the command

cabal install pandoc

I had to update cabal first.

  • 2
    You can also use Stack: stack install pandoc
    – nekketsuuu
    Oct 15 '18 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.