繁体   English   中英

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

[英]Is it possible to use asciidoc with hakyll?

我按照本教程使用hakyll创建了一个基本的静态网页。 它包括在posts目录中从markdown渲染的许多页面,例如2015-08-12-spqr.markdown

我更喜欢asciidoc而不是markdown,并尝试将asciidoc 2018-01-23_adoc 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

Arch Linux

$ pacman -S asciidoctor

红宝石宝石

$ 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 

更换pandocCompilersite.hspandocCompilerWithAsciidoctor

3.重新编译

 $ stack build $ stack exec site rebuild 

请注意,文件名必须是2018-01-23-adoc-user-manual.asciidoc而不是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

暂无
暂无

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

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