R Markdown 将标签添加到 HTML 输出的头部 [英] R Markdown Add Tag to Head of HTML Output

查看:53
本文介绍了R Markdown 将标签添加到 HTML 输出的头部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 RStudio 的 RMarkdown HTML 输出文件的头部添加 HTML 元标记?

How do I add an HTML meta tag within the head of an RMarkdown HTML output file from RStudio?

特别是我试图插入以下内容来解决我们 Intranet 上的 IE 兼容性问题.

In particular I am trying to insert the following to over come IE compatibility issues on our intranet.

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

推荐答案

您可以使用元标记创建文件并使用以下 YAML 选项添加:

You can create a file with the meta tag and add using the following YAML option:

---
title: "mytitle"
output:
  html_document:
    includes:
       in_header: myheader.html
---

您还可以在 setup chunck 中动态创建 myheader.html 文件:

You could also create the myheader.html file on the fly in the setup chunck:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE )
#libraries
require(ggplot2)

#Create myheader.html
fileConn <- file("myheader.html")
writeLines('<meta http-equiv="X-UA-Compatible" content="IE=edge" />', fileConn)
close(fileConn)
```

这篇关于R Markdown 将标签添加到 HTML 输出的头部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆