Add X-UA-Compatible in rmarkdown html output

落花浮王杯 提交于 2019-12-06 03:06:53

问题


I'm trying to add the following tag

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

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.

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.

Is there a way to add the tag as the first one automatically in rmarkdown?


回答1:


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)

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" />

Then save the html template, and point to it within YAML:

---
title: "xxx"
output:
  html_document:
    template: path/to/custom/template.html
---


来源:https://stackoverflow.com/questions/44009148/add-x-ua-compatible-in-rmarkdown-html-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!