最近发现 @yihui 又开发了一个包: highr。里面有一个函数 hi_andre
可以调用 Andre Simon 的 highlight 程序处理各种语言的高亮。我在 Rmarkdown 里针对 Maple 语言试了一下,可惜没有成功。
例如
```{r maple, echo=FALSE}
library(highr)
txt = c("f:=x^2", "D(f)(0)", "D@2(f)")
cat(hi_andre(txt, "maple", format="html"), sep = "\n")
```
会生成一段 html 代码
f<span class="hl opt">:=</span>x<span class="hl opt">^</span><span class="hl num">2</span>
<span class="hl kwb">D</span><span class="hl opt">(</span>f<span class="hl opt">)(</span><span class="hl num">0</span><span class="hl opt">)</span>
<span class="hl kwb">D</span>@<span class="hl kwd">2</span><span class="hl opt">(</span>f<span class="hl opt">)</span>
然而却没有看到 css 文件。所以代码并没有被渲染。
那位有经验的,或者有时间琢磨,能否指点一下这个包怎么配合 knitr 用?谢谢! :