如何在xaringan中突出显示单个单词或选择的代码,而不是整行?
在下面的示例中,我只想突出显示管道操作符%>%,而不是整个行。
---
output:
xaringan::moon_reader:
css: [default]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=F}图书馆(Magrittr)
Highlight Whole Line (not what I need)
```{r, eval=F}虹膜%>% #<<
摘要()
Highlight Whole Line 2 (also not what I need)
```{r, eval=F}{虹膜%>% }
摘要()
Highlight Pipe only (What I would need, doesnt work)
```{r, eval=F}虹膜{ %>% }
摘要()
Highlight Pipe only html-mark (doesnt work, as expected)
```{r, eval=F}虹膜%>%
摘要()
这导致了

任何帮助都是非常感谢的。
发布于 2018-08-25 15:07:44
我找到了一个解决方案:使用highlightSpans: true,然后在代码中使用backticks。也就是说,
---
output:
xaringan::moon_reader:
css: [default]
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
highlightSpans: true
countIncrementalSlides: false
---
```{r, eval=F}虹膜%>%
摘要()
产生

对该方法的唯一警告是,只有当R本身不计算代码时,它才会运行。(eval=TRUE将返回一个错误)
https://stackoverflow.com/questions/52016911
复制相似问题