首页 > 解决方案 > 在 YAML 标头中指定资源路径

问题描述

根据文档,我们可以使用--resource-path=...来指定资源目录的路径。例如:

---
title: Sample document
author: myself
date: now
#resource-path:
#- figures/
...

# Hi all!

Here is my sample document!  And also, there is an wonderful image in
this document.

![The wonderful image.](wimage.pdf)

Done.

该文件wimage.pdf位于figures/. 使用以下命令编译,一切正常,找到文件并嵌入到输出 PDF 文件中。

$ pandoc --resource-path=figures test.md -o test.pdf

仍然根据文档,我也可以resource-path:在 YAML 标头中使用。所以我在上面的例子中取消注释相应的 2 行,并尝试编译

$ pandoc test.md -o test.pdf
[WARNING] Could not fetch resource wimage.pdf: replacing image with description

如警告所示,图像未嵌入到输出 PDF 文件中。

YAML 标头中的是否应该resource-path:工作?

标签: pandoc

解决方案


这是对默认文件的误解。这些是包含选项的单独文件,并通过--defaults/-D命令行选项传递。放入resource-path文档的元数据将不起作用。


推荐阅读