- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 for 循环中有一个 R-markdown 文档(测试各种模型),我想用 HTML Headers 关闭它们,否则很难找到我正在寻找的模型。有 "asis"
选项,但它会关闭整个 block 的格式,这不是我想要的。我已经尝试了一些我在这里找到的东西,但没有任何效果。这是我的代码:
---
title: "Untitled"
author: "Mike Wise - 25 Jul 2014"
date: "November 2, 2015"
output: html_document
---
Test
```{r, echo=T}
for (i in 1:3){
print("<h1>Title</h1>")
#print("##Title")
m <- data.frame(matrix(runif(25),5,5))
print(m)
}
```
这是一种没有正确标题格式的尝试:
下面是 results="asis"
选项的样子:
最佳答案
好吧,一年半过去了,我仍然不时需要这个,但从那以后我学到了足够多的知识,知道如何正确地做它。你需要写一个 knitr
“输出 Hook ”,并修改输出,以便 html 可以“转义”通过。
以下实现了这一点:
knitr
输出 Hook 。<h1>some_text</h1>
使用 htmlesc<<(h1,some_text)>>
h1
的正则表达式和 some_text
并将其重新格式化为正确标记的 html,删除 ##
那knitr
也插入了。h4
、 p
、图表和表格的正确放置等)代码如下:
---
title: "Output Hook for HTML Escape"
author: "Someone"
date: "2017 M04 25"
output:
html_document:
keep_md: true
---
```{r setup, include=T,echo=TRUE}
knitr::opts_chunk$set(echo = TRUE)
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output=function(x,options){
xn <- hook_output(x,options)
# interestingly xn is a big character string.
# I had expected a list or vector, but the length of x is 1 and the class is character.
# The following regexp extracts the parameters from a statement of the form
# htmlesc<<(pat1,pat2)>> and converts it to <pat1>pat2</pat1>
xn <- gsub("## htmlesc<<([^,]*),{1}([^>>]*)>>","\n```\n<\\1>\\2</\\1>\n```\n",xn)
# now remove double escaped lines that occur when we do these right after each other
gsub(">\n```\n\n\n```\n<",">\n<",xn)
}
)
```
## An analysis loop in a single R chunk with R Markdown
In the following, we do a loop and generate 3 sets of data:
(@) We have some explanitory text
(@) then we do a bar plot with ggplot
(@) then we print out a table
(@) then we do a base plot - just for fun
```{r, echo=T, fig.height=3,fig.width=5}
library(knitr)
library(tidyr)
library(ggplot2)
set.seed(123)
for (i in 1:3){
mdf <- data.frame(matrix(runif(25),5,5))
cat(sprintf("htmlesc<<h1,Title %d>>\n",i))
cat(sprintf("htmlesc<<h4,Smaller Title - also for %d>>\n",i))
cat(sprintf("htmlesc<<p,and some text talking about this %d example>>\n",i))
print(sapply(mdf,mean))
gdf <- gather(mdf,series,val)
gp <- ggplot(gdf)+geom_bar(aes(series,val,fill=series,color=I("black")),stat="identity")
print(gp)
print(mdf)
plot(mdf)
}
```
这是输出(由于您不需要详细信息而缩小了一点)。
顺便说一下,唯一真正的文档是 Yihui 的优秀 knitr 书,搜索很容易找到它。
关于单行 R-markdown block 内的 HTML 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33478874/
这是我的代码片段:http://www.share-elm.com/sprout/53d242e2e4b07afa6f9834a2灵感来自 elm-lang.org 的 example . main
抱歉,如果这个问题有点基础,但互联网上的研究并没有得出任何合理的答案。我希望能够在我的网站上运行 markdown,类似于 github 所拥有的(编辑/预览设置)或实际上与 stackoverflo
我正在使用 markdown 编写文档,我正在使用 pandoc 将其导出为 PDF。在文档的末尾,我需要在 PDF 的打印副本上留出签名空间。 我试图找到如何绘制一条固定宽度的线,但到目前为止我只需
我已经搜索过谷歌和 SO,不知道 SO 是否是问这个的地方,但我想知道是否有标记可以为 Markdown 做某种类型的注释?我们在 Markdown 中为我们的项目做文档,并希望在不更改内容的情况下在
我想使用简单的文本编辑器和 Markdown 做类笔记。有没有办法标记文本元素以使其机器可读? 例如,我想将某些单词和短语标记为“定义”。然后,我可以运行某种脚本来显示单词及其相应的定义。 最佳答案
我有两个markdown文件:一个parent.md和child.md。 所以parent.md: # Main section ## sub-section 我想引用## sub-section中的
我需要在 Markdown 中创建一个类似嵌套的表,如下所示: 我怎样才能做到这一点? 最佳答案 @Waylan 是对的,您可以将 HTML(例如使用 Markdown 生成的表格)粘贴到 Markd
有没有办法在 Github markdown 的代码片段中链接表单? 例如:`I want THIS to be a link`哪里THIS看起来像 THIS . 最佳答案 我想通过 Markdown
我正在 Github 风格的 Markdown 中整理一些文档,并且我想整理一个有两行的表格。一种是简单的文本,另一种是 json 代码块。这是一个例子。 | Status | Response |
使用 GitHub 上“Markdown Cheatsheet ”中的表示例,您会得到以下结果: | Tables | Are | Cool | | -------
我对 Markdown 中的引号有疑问。当我有这样的事情时: text > quoted text > > deeper layer > > > even deeper
我正在寻找与 Markdown 中的多行代码功能等效的引号。对于代码块我可以方便地编写: ``` this is a code example ``` 有谁知道下面的事情是否可能? >>>
我想在 Markdown 中创建一个列表,但没有项目符号点。这可能吗? 到目前为止,我发现唯一推荐的方法是使用 HTML,我想避免使用 HTML。 最佳答案 这听起来似乎很明显,但是......您可以
我想编写一份编码标准规范文档,其中包含好和坏编码示例。每条规则都应该有一个编号、描述和示例。 例如,这是规则 1: # Rule 1 Description for rule 1. ## Good `
可以关注Marked library documentation并内联渲染一个 Markdown 字符串。这是一个有效的代码片段。 document.getElementById
据我所知,markdown 是 html 的“简化”版本。它易于使用和阅读。但我在创建输入表单时遇到了问题。 有人可以建议是否有任何方法可以在 Markdown 中添加 html 输入表单元素吗?我搜
如何在 Markdown 解析文档中包含小书签?是否有任何 Markdown 的“标签”基本上是说“不要解析这个”?? 例如,您可以有类似的内容: Hello 但是如果我尝试将其中的 JavaScri
可以关注Marked library documentation并内联渲染一个 Markdown 字符串。这是一个有效的代码片段。 document.getElementById
我想编写一个 R Markdown 文档,其中提供了如何编写 R Markdown 文档的代码示例。例如,我想在文档中展示如何将文本呈现为粗体。 `**this is bold**` will ren
我目前正在使用 GitHub 页面构建一个网站,并尝试利用一些 GitHub 风格的 Markdown 功能。特别隔离的代码块和表。 使用 redcarpet,我得到语法突出显示的围栏 block ,
我是一名优秀的程序员,十分优秀!