3

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

includes.hs:3:8:
    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!

1 Answer 1

8

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.

1
  • 2
    You can also use Stack: stack install pandoc
    – nekketsuuu
    Oct 15, 2018 at 2:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .