daviddalpiaz / bsl

:chart_with_upwards_trend: Machine Learning from the perspective of a Statistician using R
https://statisticallearning.org
16 stars 10 forks source link

Inline syntax highlighting #13

Open coatless opened 4 years ago

coatless commented 4 years ago

Override inline code styling, e. g. code = 1 + 1 to have syntax highlighting, e.g.

code = 1+ 1

Need a common.R file that loads

library(knitr)
hook_inline = knit_hooks$get('inline')
knit_hooks$set(inline = function(x) {
      if (is.character(x)) highr::hi_html(x) else hook_inline(x)
})

c.f. https://stackoverflow.com/questions/18643863/consistent-code-html-inline-and-in-chunks-with-knitr