![](/img/trans.png)
[英]How to convert tables in markdown file into html file using pandoc
[英]Pandoc cannot find image path referenced in external HTML file pulled into R Markdown, despite using here() package
我正在通过 R Markdown 生成 HTML 文档,该文档使用一些外部 Z4C4AD5FCA2E7A3F74DBB1ACED 文档和页脚。 我还使用 here() package 来允许整个项目中的相对路径。 但是,当使用 YAML 通过 R 代码包含外部 HTML 时,这些文件中的相对路径不起作用。
这是 R Markdown 的 YAML header
---
title: "Test"
output:
html_document:
includes:
in_header: !expr "here::here('FORMATTING','favicon.html')"
---
文件“favicon.html”具有以下代码:
<link rel="icon" type="image/png" href="favicon.ico"/>
我的文件夹结构是:
Main
│ └──.here
├──SCRIPTS
│ └──test_code.Rmd
├──FORMATTING
│ └──favicon.html
│ └──favicon.ico
当我使用 RStudio 中的“编织”按钮运行脚本时,出现以下错误:
File favicon.ico not found in resource path
Error: pandoc document conversion failed with error 99
似乎 pandoc 可以使用 R 代码很好地找到 HTML 文件,但它似乎需要实际图像的绝对文件路径。
如何确保 pandoc 找到图像而不必求助于绝对路径?
我habe完全一样的问题。 Modern_ibex ( <link rel="icon" type="image/png" href=".\..\FORMATTING\favicon.ico"/>
)提出的解决方案对我不起作用。
我的 favicon.html 和 logo.png 存储在文件夹“数据”中。 在 favicon.html 中: "<link rel="shortcut icon" href="Data/logo.png" />"
project.Rproj
|
|___ Data (- favicon.html
| - logo.png)
|
|___ Scripts
|__ Rmds (- my file.rmd)
|
|__ ...
我的 rmd 文件存储在“脚本/Rmds”中。 我的 YAML 看起来像:
title: "Analysis"
author: "me"
date: "`r format(Sys.time(), '%d. %B %Y')`"
output:
html_document:
includes:
in_header: !expr here::here("Data/favicon.html")
运行时我收到一条错误消息:在资源路径中找不到文件数据/logo.png 错误:pandoc 文档转换失败并出现错误 99所以 favicon.html 已读取,但未解释 href。 我在 favicon.html 中用 ~ 或尝试了 divers href。 或.. 或 / 或 \ 或 r 代码但没有结果。
提前感谢您的帮助!
我的解决方案:
在.Rmd YAML
:
title: "Analysis"
author: "me"
date: "`r format(Sys.time(), '%d. %B %Y')`"
output:
html_document:
includes:
in_header: !expr here::here("Data/favicon.html")
在favicon.html
中:
<link rel="shortcut icon" href="../../Data/logo.png" />
文件结构:
project.Rproj
|
|___ Data (- favicon.html
| - logo.png)
|
|___ Scripts
|__ Rmds (- my file.rmd)
|
|__ ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.