在rmarkdown html输出中添加X-UA-Compatible [英] Add X-UA-Compatible in rmarkdown html output
问题描述
我正在尝试添加以下标签
I'm trying to add the following tag
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
在rmkardown HTML文档的输出中,
是<header>
之后的第一个.正如本MSDN 文章.
as the first one after <header>
in the output of rmkardown HTML document. This is necessary for Internet Explorer, as explained in this MSDN article.
此 answer 对我不起作用因为该标记被添加在<head>
的末尾并且被忽略.我的HTML输出中嵌入了一些脚本,这些脚本写在X-UA-Compatible元标记之前.
This answer does not work for me because the tag is added at the end of <head>
and is ignored. My HTML output has some script embedded that is written before the X-UA-Compatible meta tag.
是否有一种方法可以在rmarkdown中自动将标签添加为第一个标签?
Is there a way to add the tag as the first one automatically in rmarkdown?
推荐答案
我也遇到了这个问题.正如人们在评论中所说,编辑rmarkdown使用的模板html文件是可行的.我复制并编辑了保存在大约"C:\ Users \ ProfileX \ Documents \ R \ win-library \ 3.4 \ rmarkdown \ rmd \ h \ default.html"中的模板(感谢@ visu-l)
I just ran into this issue too. As people have said in the comments, editing the template html file used by rmarkdown works. I copied and edited the template saved at approximately "C:\Users\ProfileX\Documents\R\win-library\3.4\rmarkdown\rmd\h\default.html" (thanks @visu-l)
您要将该标签添加为<head>
中的第一个标签:
You want to add the tag as the first one within <head>
:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
然后保存html模板,并在YAML中指向它:
Then save the html template, and point to it within YAML:
---
title: "xxx"
output:
html_document:
template: path/to/custom/template.html
---
这篇关于在rmarkdown html输出中添加X-UA-Compatible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!