我正在使用 knit 生成 HTML 报告,并且我想包含作者和生成日期元标记。
我的 Rhtml 页面看起来像这样。
<html>
<head>
<meta name="author" content="<!--rinline Sys.getenv('USERNAME') -->">
<meta name="date" content="<!--rinline as.character(Sys.time()) -->">
</head>
<body>
</body>
</html>
不幸的是,之后我knit("test.Rhtml")
,knitr 生成的 HTML 是
<meta name="author" content="<code class="knitr inline">RCotton</code>">
<meta name="date" content="<code class="knitr inline">2013-01-02 14:38:16</code>">
这不是有效的 HTML。我真正想要生成的是类似的东西
<meta name="author" content="RCotton">
<meta name="date" content="2013-01-02 14:38:16">
我可以生成没有得到的 R 代码吗code
标签包装吗?或者是否有另一种方法来指定标签属性(如这些内容属性)?
到目前为止,我最糟糕的计划是手动修复内容readLines
/str_replace
/writeLines
,但这看起来相当笨拙。
另一种(未记录的)方法是添加I()
在内联代码周围按原样打印字符而无需<code>
标签,例如
<html>
<head>
<meta name="author" content="<!--rinline I(Sys.getenv('USERNAME')) -->">
<meta name="date" content="<!--rinline I(as.character(Sys.time())) -->">
</head>
<body>
</body>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)