Compiling Pandoc Haskell script: Could not find module `Text.Pandoc.JSON'

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!

Richard Herron

Posted 2014-08-14T14:54:14.803

Reputation: 1 027

Answers

7

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.

Richard Herron

Posted 2014-08-14T14:54:14.803

Reputation: 1 027

2You can also use Stack: stack install pandoc – nekketsuuu – 2018-10-15T02:33:40.523