繁体   English   中英

Hakyll的定制Pandoc作家

[英]Custom pandoc writer with Hakyll

我正在尝试编写一个特殊的Hakyll编译器,以使用lua脚本来构建我的网站。 我发现这个功能可以使我想要的东西:

customWriterCompilerWith :: (WriterOptions -> Pandoc -> IO String)
                         -> ReaderOptions -> WriterOptions
                         -> Compiler (Item String)
customWriterCompilerWith customWriter ropt wopt = do
    body <- getResourceBody
    withItemBody (unsafeCompiler . customWriter wopt) $ readPandocWith ropt body

但是,当我尝试编译此函数时,出现此错误:

• Couldn't match expected type ‘Item Pandoc’
              with actual type ‘Compiler (Item Pandoc)’
• In the second argument of ‘($)’, namely
    ‘readPandocWith ropt body’

在Hakyll文档中搜索之后,版本4.6.8.04.9.8.0 (我的版本)中的readPandocWith类型有所不同:

readPandocWith:: ReaderOptions-> Item String-> Item Pandoc -- 4.6.8.0

readPandocWith:: ReaderOptions-> Item String-> Compiler (Item Pandoc) -- 4.9.8.0

我在Hakyll文档中没有找到可以帮助我的函数(其类型应为Compiler (Item Pandoc)-> Item Pandoc )。

你知道如何解决这个问题吗?

您知道用LUA脚本制作自定义Hakyll编译器的另一种方法吗?

正如@ user2407038所提到的,以下应该起作用:

customWriterCompilerWith customWriter ropt wopt = do
    body <- getResourceBody
    doc  <- readPandocWith ropt body
    withItemBody (unsafeCompiler . customWriter wopt) doc

要了解有关<->>=语法糖)的更多信息,我可以推荐http://learnyouahaskell.com (monad章节)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM