gpt4 book ai didi

haskell - 是否可以将 asciidoc 与 hakyll 一起使用?

转载 作者:行者123 更新时间:2023-12-01 08:45:47 26 4
gpt4 key购买 nike

我关注了 this tutorial使用 hakyll 创建一个基本的静态网页。它包括许多从 posts 中的 Markdown 呈现的页面。目录,例如2015-08-12-spqr.markdown .

我更喜欢 asciidoc 而不是 Markdown ,并尝试添加一个 asciidoc 2018-01-23_adoc-user-manual.asciidocpost目录。
然而,hakyll尝试编译页面时抛出错误:

Initialising...
Creating store...
Creating provider...
Running rules...
Checking for out-of-date items
Compiling
updated templates/default.html
updated about.rst
updated templates/post.html
updated posts/2015-08-12-spqr.markdown
updated posts/2015-10-07-rosa-rosa-rosam.markdown
updated posts/2015-11-28-carpe-diem.markdown
updated posts/2015-12-07-tu-quoque.markdown
[ERROR] Hakyll.Web.readPandocWith: I don't know how to read a file of the type Binary for: posts/2018-01-23_adoc-user-manual.asciidoc
CallStack (from HasCallStack):
error, called at lib/Hakyll/Web/Pandoc.hs:66:31 in hakyll-4.12.5.0-8ZITvFN5YREEKv6B76SCAd:Hakyll.Web.Pandoc

这个问题是 pandocCompiler 无法处理 asciidoc ?
是否可以使用 asciidochakyll ?

最佳答案

当前的 Pandoc 可以写 Asciidoc 但不能读取它: Issue

此外,似乎没有用 Haskell 编写的 Asciidoc 解析器,因此没有纯粹的 Haskell 解决方案。

但是,Hakyll 有 unixFilter,它可以使用任何从 stdin 输入并输出到 stdout 的命令。因此,您可以调用 asciidoctor 命令来转换 .asciidoc 文件。

这是步骤:

1.安装asciidoctor

Ubuntu
$ apt-get install asciidoctor
软呢帽
$ dnf install asciidoctor
拱形Linux
$ pacman -S asciidoctor
ruby
$ gem install asciidoctor
2. 定义 pandocCompilerWithAsciidoctor

将以下代码添加到 site.hs

pandocCompilerWithAsciidoctor :: Compiler (Item String)
pandocCompilerWithAsciidoctor = do
extension <- getUnderlyingExtension
if extension == ".asciidoc" then
getResourceString >>= withItemBody (unixFilter "asciidoctor" ["-"])
else
pandocCompiler

pandocCompiler 替换 site.hs 中的 pandocCompilerWithAsciidoctor
3.重新编译
$ stack build
$ stack exec site rebuild

请注意,文件名必须是 2018-01-23-adoc-user-manual.asciidoc 而不是 2018-01-23_adoc-user-manual.asciidoc ,否则会出现错误: [ERROR] Missing field $date$ in context for item posts/2018-01-23_adoc-user-manual.asciidoc

关于haskell - 是否可以将 asciidoc 与 hakyll 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54338415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com