For bookdown
, I'm working on recreating inline code formatting that is similar to what is produced in chunks (see this old SO issue). My current approach is:
local({
hook_old <- knitr::knit_hooks$get("inline")
knitr::knit_hooks$set(inline = function(x, options) {
if (is.character(x) & knitr::is_html_output()) {
highr::hi_html(x)
} else {
hook_old(x, options)
}
})
})
but that produces an empty html file for the chapter that attempts to use
`r 'lm(y ~ x, data = dat)'`
There is a reproducible repo at topepo/bookdown-inline
; see 01-intro.Rmd
.
Generally, I suspect that the whole approach is different in bookdown
.