我很抱歉提出这样的问题.但我对Haskell真的很新.我在互联网上搜索了一整天,但没有找到任何例子.
我有一个用python(tikzcd.py)编写的pandoc过滤器.我想使用该过滤器来处理我的博客帖子.
我想我需要使用unixFilter或者pandocCompileWithTransform我对Haskell的知识真的不足以自己找到解决方案.
那么,有人能为我提供一个例子吗?
- - - - - -更新 - - - - - - - -
@Michael使用pandocCompileWithTransformM和提供解决方案unixFilter.有用.但有一个问题.
从命令行使用过滤器时,我要做的是
pandoc -t json -READEROPTIONS input.markdown | ./filter.py | pandoc -f JSON -WRITEROPTIONS -o output.html
Run Code Online (Sandbox Code Playgroud)
或者等价的Run Code Online (Sandbox Code Playgroud)pandoc --filter ./filter.py -READEROPTIONS -WRITEROPTIONS -o html
此命令较短但不显示过程.
但是pandocCompilerTransformM,它确实有类似的东西
pandoc -t html -READEROPTIONS -WRITEROPTIONS input.mardown | pandoc -t JSON | ./filter.py | pandoc -f JSON -WRITEROPTIONS -o output.html
Run Code Online (Sandbox Code Playgroud)
不同之处在于传递给的文本filter.py是不同的:一个是直接从markdown生成的内容,另一个是从markdown生成的HTML文本.如你所知,来回转换东西总会产生意想不到的问题.所以我认为可能有更好的解决方案.
PS.我盯着学习Haskell.我希望有一天我能自己解决这个问题.谢谢!
我正在尝试在新的Ubuntu 16.04实例上设置Hakyll,但似乎无法正确理解基于堆栈的安装说明。
从开始stack install hakyll,我得到:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for hakyll-4.9.3.0:
http-conduit-2.1.11 must match >=2.2 && <2.3 (latest applicable is 2.2.3)
Plan construction failed.
Run Code Online (Sandbox Code Playgroud)
绑定到时stack-install http-conduit-2.1.11,出现了类似的错误:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for http-conduit-2.2.3:
http-client-0.4.31.2 must match >=0.5 && <0.6 (latest applicable is 0.5.5)
http-client-tls-0.2.4.1 must match >=0.3 && <0.4 (latest applicable is 0.3.3.1) …Run Code Online (Sandbox Code Playgroud) 我想根据元数据值过滤我网站的一些帖子。我想创建一个名为status(like titleor date)的特定元数据,它可以采用多个值(草稿、已发布、存档):
---
title: The title
author: Myself
date: 2016-11-29
tags: tag1, tag2
status: draft
---
Run Code Online (Sandbox Code Playgroud)
根据status元数据的价值,该帖子是否应该发布。
我查看了 hackage 文档,但不确定要使用的功能。
你知道如何用 Hakyll 做到这一点吗?
我按照本教程使用hakyll创建了一个基本的静态网页.它包括从posts目录中的markdown呈现的多个页面,例如2015-08-12-spqr.markdown.
我更喜欢asciidoc到markdown,并尝试2018-01-23_adoc-user-manual.asciidoc在post目录中添加asciidoc .但是,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
Run Code Online (Sandbox Code Playgroud)
这个问题pandocCompiler无法处理asciidoc吗?是否有可能使用asciidoc与hakyll?
我正在按照https://jaspervdj.be/hakyll/tutorials/01-installation.html 中的 Hakyll 教程进行操作。
但似乎有些不对劲,我说不出是什么。当我运行 'stack init' 时,我收到此消息。
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- ./
Selecting the best among 16 snapshots...
* Partially matches lts-14.16
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches nightly-2019-11-25
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches lts-13.30
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches lts-12.26
hakyll version 4.12.4.0 found
- ourblog-com requires ==4.13.*
* Partially …Run Code Online (Sandbox Code Playgroud) 我正在尝试用Hakyll库写一个项目.为了避免弄乱我的系统,我将它安装在我的Hakyll项目所在的同一文件夹中的cabal沙箱中.
或多或少是一个初学者,我仍然在努力使害虫做法正确.一个简单的方法就是这样做
$ cabal sandbox init
$ cabal install hakyll
$ cabal exec ghc -- --make site.hs
Run Code Online (Sandbox Code Playgroud)
最后一行使用沙箱中的库编译我的Hakyll生成器.明显的缺点是这是不可再现的.当我尝试从干净的结账再次运行时,Hakyll的主要版本可能会发生变化.
另一种方法是编写一个适当的project.cabal文件(例如像:chromaticleaves.cabal),然后做cabal install或cabal run.
但是,我觉得这可能是一个太多的信息.由于我不打算发布这个项目,我不是真的相信我需要在那里放置一个项目名称和版本号.(例如,在Ruby中Gemfile,我也只会指定库而不是其他内容,除非我想自己发布一个gem.)
所以,最终我想到了一个类似的文件
$ cat project.cabal
cabal-version: >= 1.2
library
build-depends: base >=4.6
, containers
, process
, hakyll >=4.5
, pandoc
, pandoc-types
Run Code Online (Sandbox Code Playgroud)
我可以打字
$ cabal sandbox init
$ cabal install --only-dependencies
$ cabal exec ghc -- --make site.hs
Run Code Online (Sandbox Code Playgroud)
它似乎下载所有依赖项,并能够编译该文件.
这是一个合理的方法,还是真正的最佳实践,在cabal文件中提供名称,版本和可执行部分的完整规范?
编辑:显然,我的方法不允许我这样做cabal repl.所以要么存在一种完全不同的方式,要么似乎我必须采用更全面的规范.
我正在尝试用Travis-CI建立我的Hakyll网站.但是,在我达到目前为止,在尝试将Hakyll安装为依赖项时,我遇到了依赖项错误.
我可以在我的机器上本地建造Hakyll而没有任何问题.什么可能导致依赖性错误,以及如何解决?有没有办法解决它而不实际硬编码每个依赖版本?
这是来自TravisCI的输出.
travis_fold:end:git.5
$ export PATH=/usr/local/ghc/$(ghc_find 7.6)/bin/:$PATH
travis_fold:start:cabal
$ cabal update
Config file path source is default config file.
Config file /home/travis/.cabal/config not found.
Writing default configuration to /home/travis/.cabal/config
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
travis_fold:end:cabal
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
$ cabal --version
cabal-install version 1.18.0.2
using version 1.18.1 of the Cabal library
travis_fold:start:before_install.1
$ cabal …Run Code Online (Sandbox Code Playgroud)