我正在尝试使用Pandoc 脚本页面中的一个罐头示例,但我对 Haskell 的了解不够充分,无法完成这项工作。这是脚本。
#!/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
Run Code Online (Sandbox Code Playgroud)
我将其另存为includes.hs. 要将其用作 Panodc 过滤器,我需要对其进行编译,因此我运行了ghc --make include.hs,但出现以下错误。
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.
Run Code Online (Sandbox Code Playgroud)
不是Text.PANDOC.JSON和 Pandoc 一起安装的吗?我找不到有关如何安装软件包的任何信息。我会以错误的方式解决这个问题吗?谢谢!
我在这个相关的 SO 问题中找到了答案。我需要将 Pandoc 库添加到 Haskell。
这是命令
cabal install pandoc
Run Code Online (Sandbox Code Playgroud)
我必须先更新 cabal。