我有一个示例书项目,带有gitbook输出
index.Rmd:
---
title: "An Example Project"
author: "Coderoo"
output:
bookdown::gitbook: default
pandoc_args: ["--lua-filter=hello.lua"]
documentclass: book
---
Some text {{helloworld}}
hello.lua直接从pandoc lua过滤器文档中获取:
return {
{
Str = function (elem)
if elem.text == "{{helloworld}}" then
return pandoc.Emph {pandoc.Str "Hello, World"}
else
return elem
end
end,
}
}
但是当我尝试制作这本书时:
Rscript -e "bookdown::render_book('index.Rmd','bookdown::gitbook')"
我收到此错误:
Error in yaml::yaml.load(..., eval.expr = TRUE) :
Scanner error: mapping values are not allowed in this context at line 5, column 16
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous> -> .Call
Please delete _main.Rmd after you finish debugging the error.
Execution halted
如果我将YAML元数据中的bookdown::gitbook default
替换为html_document
,那么一切正常。
也交叉发布在这里:https://community.rstudio.com/t/how-to-use-lua-filter-with-gitbook-output/48256
编辑:在rstudio论坛中回答。