作者:靠谱的郭大虾_938 | 来源:互联网 | 2022-12-06 17:15
如何在xaringan中突出显示单个单词或选择的代码而不是整行?
在下面的例子中,我想只突出显示管道操作符%>%
而不是整行.
---
output:
xaringan::moon_reader:
css: [default]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=F}
library(magrittr)
```
Highlight Whole Line (not what I need)
```{r, eval=F}
iris %>% #<<
summary()
```
Highlight Whole Line 2 (also not what I need)
```{r, eval=F}
{{ iris %>% }}
summary()
```
Highlight Pipe only (What I would need, doesnt work)
```{r, eval=F}
iris {{ %>% }}
summary()
```
Highlight Pipe only html-mark (doesnt work, as expected)
```{r, eval=F}
iris %>%
summary()
```
结果如此
任何帮助表示赞赏.
1> David..:
我找到了一个解决方案:highlightSpans: true
在代码中使用然后使用反引号.也就是说,
---
output:
xaringan::moon_reader:
css: [default]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
highlightSpans: true
countIncrementalSlides: false
---
```{r, eval=F}
iris `%>%`
summary()
```
产生
该方法的唯一警告是它只在R本身不评估代码时运行.(eval=TRUE
会返回错误)
其来源是:https://github.com/gnab/remark/wiki/Configuration